diff options
| -rw-r--r-- | .config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml | 1 | ||||
| -rwxr-xr-x | .local/bin/amdgpu-toggle-tearfree-x11 | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml b/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml index ad614f4..567816e 100644 --- a/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml +++ b/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml | |||
| @@ -63,6 +63,7 @@ | |||
| 63 | <property name="<Super>c" type="string" value="toggle-xfwm4-compositor"/> | 63 | <property name="<Super>c" type="string" value="toggle-xfwm4-compositor"/> |
| 64 | <property name="<Primary><Alt>Delete" type="string" value="xterm -geometry 95x28 -e htop"/> | 64 | <property name="<Primary><Alt>Delete" type="string" value="xterm -geometry 95x28 -e htop"/> |
| 65 | <property name="<Primary><Shift>Escape" type="string" value="gnome-system-monitor"/> | 65 | <property name="<Primary><Shift>Escape" type="string" value="gnome-system-monitor"/> |
| 66 | <property name="<Alt><Super>t" type="string" value="amdgpu-toggle-tearfree-x11"/> | ||
| 66 | </property> | 67 | </property> |
| 67 | </property> | 68 | </property> |
| 68 | <property name="xfwm4" type="empty"> | 69 | <property name="xfwm4" type="empty"> |
diff --git a/.local/bin/amdgpu-toggle-tearfree-x11 b/.local/bin/amdgpu-toggle-tearfree-x11 new file mode 100755 index 0000000..c7b1ebc --- /dev/null +++ b/.local/bin/amdgpu-toggle-tearfree-x11 | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # requires: xrandr, awk | ||
| 4 | |||
| 5 | err() { | ||
| 6 | printf "%s\n" "$*" >&2 | ||
| 7 | exit 1 | ||
| 8 | } | ||
| 9 | |||
| 10 | for cmd in xrandr awk; do | ||
| 11 | command -v "$cmd" >/dev/null 2>&1 || err "required command not found: $cmd" | ||
| 12 | done | ||
| 13 | |||
| 14 | # collect all connected outputs | ||
| 15 | outputs=$(xrandr --query | awk '/ connected/ { print $1 }') | ||
| 16 | |||
| 17 | [ -n "$outputs" ] || err "no connected outputs found." | ||
| 18 | |||
| 19 | # sample TearFree state from the first connected output | ||
| 20 | first_output=$(printf '%s\n' "$outputs" | awk 'NR==1') | ||
| 21 | current_state=$(xrandr --props | awk -v out="$first_output" ' | ||
| 22 | $1 == out { found=1 } | ||
| 23 | found && /TearFree:/ { print $2; exit } | ||
| 24 | ') | ||
| 25 | |||
| 26 | case "$current_state" in | ||
| 27 | on) new_state="off" ;; | ||
| 28 | *) new_state="on" ;; | ||
| 29 | esac | ||
| 30 | |||
| 31 | # single xrandr invocation, avoids monitor reconfiguration for the most part | ||
| 32 | xrandr_args="" | ||
| 33 | for output in $outputs; do | ||
| 34 | xrandr_args="$xrandr_args --output $output --set TearFree $new_state" | ||
| 35 | done | ||
| 36 | |||
| 37 | # shellcheck disable=SC2086 | ||
| 38 | xrandr $xrandr_args || err "failed to set TearFree $new_state on all outputs" | ||
| 39 | |||
| 40 | notify-send "AMDGPU (X11)" "TearFree $new_state" -t 3072 \ | ||
| 41 | || printf "TearFree toggled to '%s' on all connected outputs.\n" "$new_state" | ||
