summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml1
-rwxr-xr-x.local/bin/amdgpu-toggle-tearfree-x1141
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="&lt;Super&gt;c" type="string" value="toggle-xfwm4-compositor"/> 63 <property name="&lt;Super&gt;c" type="string" value="toggle-xfwm4-compositor"/>
64 <property name="&lt;Primary&gt;&lt;Alt&gt;Delete" type="string" value="xterm -geometry 95x28 -e htop"/> 64 <property name="&lt;Primary&gt;&lt;Alt&gt;Delete" type="string" value="xterm -geometry 95x28 -e htop"/>
65 <property name="&lt;Primary&gt;&lt;Shift&gt;Escape" type="string" value="gnome-system-monitor"/> 65 <property name="&lt;Primary&gt;&lt;Shift&gt;Escape" type="string" value="gnome-system-monitor"/>
66 <property name="&lt;Alt&gt;&lt;Super&gt;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
5err() {
6 printf "%s\n" "$*" >&2
7 exit 1
8}
9
10for cmd in xrandr awk; do
11 command -v "$cmd" >/dev/null 2>&1 || err "required command not found: $cmd"
12done
13
14# collect all connected outputs
15outputs=$(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
20first_output=$(printf '%s\n' "$outputs" | awk 'NR==1')
21current_state=$(xrandr --props | awk -v out="$first_output" '
22 $1 == out { found=1 }
23 found && /TearFree:/ { print $2; exit }
24')
25
26case "$current_state" in
27 on) new_state="off" ;;
28 *) new_state="on" ;;
29esac
30
31# single xrandr invocation, avoids monitor reconfiguration for the most part
32xrandr_args=""
33for output in $outputs; do
34 xrandr_args="$xrandr_args --output $output --set TearFree $new_state"
35done
36
37# shellcheck disable=SC2086
38xrandr $xrandr_args || err "failed to set TearFree $new_state on all outputs"
39
40notify-send "AMDGPU (X11)" "TearFree $new_state" -t 3072 \
41 || printf "TearFree toggled to '%s' on all connected outputs.\n" "$new_state"