Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # The window names we are looking for
- TARGET_WINDOWS=("Europa Universalis IV" "World of Warships")
- # The xinput device name
- DEVICE_NAME="SINOWEALTH ADXM0620"
- # Previous window state
- PREV_STATE=""
- while true; do
- # Get the name of the currently focused window
- CURRENT_WINDOW=$(xdotool getwindowfocus getwindowname)
- # Flag to check if any target window is focused
- WINDOW_MATCH=false
- # Loop through all target windows
- for TARGET_WINDOW in "${TARGET_WINDOWS[@]}"; do
- if [[ "$CURRENT_WINDOW" == *"$TARGET_WINDOW"* ]]; then
- WINDOW_MATCH=true
- if [[ "$PREV_STATE" != "focused" ]]; then
- # If previously unfocused, now focused on one of the target windows
- xinput --set-prop "$DEVICE_NAME" 'libinput Scroll Method Enabled' 0, 0, 0
- PREV_STATE="focused"
- fi
- fi
- done
- # If no target windows are focused
- if [[ "$WINDOW_MATCH" == false ]]; then
- if [[ "$PREV_STATE" != "unfocused" ]]; then
- # If previously focused, now unfocused
- xinput --set-prop "$DEVICE_NAME" 'libinput Scroll Method Enabled' 0, 0, 1
- PREV_STATE="unfocused"
- fi
- fi
- # Sleep for a short while before checking again (adjust as needed)
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment