gamemodelist 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Created by Sam Gleske
  3. # Created Sat Jan 1 16:56:54 EST 2022
  4. # MIT License - https://github.com/samrocketman/home
  5. # DESCRIPTION
  6. # Find all running processes which have loaded Feral Interactive gamemode
  7. # via libgamemodeauto.so. This script will not detect processes which load
  8. # gamemode without libgamemodeauto.so.
  9. # DEVELOPMENT ENVIRONMENT
  10. # Ubuntu 18.04.6 LTS
  11. # Linux 5.4.0-91-generic x86_64
  12. # GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
  13. # find (GNU findutils) 4.7.0-git
  14. # GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)
  15. # xargs (GNU findutils) 4.7.0-git
  16. # ps from procps-ng 3.3.12
  17. if [ -z "${USER:-}" ]; then
  18. echo '$USER variable not defined.' >&2
  19. exit 1
  20. fi
  21. if [ ! -d /proc ]; then
  22. echo 'ERROR: /proc filesystem missing. We do not appear to be running on Linux.' >&2
  23. exit 1
  24. fi
  25. find /proc -maxdepth 2 -type f -user "${USER}" -readable -name maps -exec \
  26. awk -- 'BEGINFILE { if (ERRNO) nextfile } $0 ~ /libgamemodeauto\.so\.0/ {pid=FILENAME; gsub("[^0-9]", "", pid); print pid;nextfile}' {} + \
  27. | xargs | xargs -I{} -- ps -o pid,ppid,user,ni,psr,comm --pid '{}'