A utility for automatically running .sh
scripts when the Counter-Strike 2 (CS2) window gains or loses focus on Ubuntu (X11).
- Automatically executes scripts when switching focus to or from the CS2 window.
- Includes:
- Disabling the Super key when CS2 is focused.
- Switching between 4:3 and 16:9 resolutions.
Designed to work under X11 on Ubuntu.
-
Copy Scripts: The
/scripts/
folder containing the scripts can be placed anywhere on your system. -
Set Permissions: Ensure all files in the
/scripts/
directory have execution permissions:chmod +x ./scripts/*.sh
-
Run Focus Listener: Start the focus listener script manually:
./scripts/cs2-focus-listener.sh
- When the CS2 window gains focus,
focus-cs2.sh
will execute. - When the CS2 window loses focus,
unfocus-cs2.sh
will run.
- When the CS2 window gains focus,
To automatically run the focus listener service on login:
-
Move Service File: Place the
cs2-focus-listener.service
file under/etc/systemd/user/
-
Modify Paths: Update the paths in
cs2-focus-listener.service
to match the location of your scripts. -
Reload Daemon: Reload systemd to recognize the new service:
systemctl --user daemon-reload
-
Enable Service on Login: Add the following command to Startup Applications:
systemctl --user start cs2-focus-listener.service
To start the service immediately without waiting for the next login, run the same command.
-
Check Service Status: Verify if the service is active:
systemctl --user status cs2-focus-listener.service
This setup ensures that the service starts automatically when you log in.