summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkj_sh604 <43.splash@gmail.com>2026-02-19 23:39:27 -0500
committerkj_sh604 <43.splash@gmail.com>2026-02-19 23:39:27 -0500
commitdd8867a5a0eb704bffdfc996e714874abba537db (patch)
treeb9bad8fca192b6e73e385ef4d3c34a050edf64ca
parenta7caf7d946b9c5c9c3453e42b5b7c69dcca54a86 (diff)
feat: amdgpu-toggle-tearfree-x11
-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 @@
<property name="&lt;Super&gt;c" type="string" value="toggle-xfwm4-compositor"/>
<property name="&lt;Primary&gt;&lt;Alt&gt;Delete" type="string" value="xterm -geometry 95x28 -e htop"/>
<property name="&lt;Primary&gt;&lt;Shift&gt;Escape" type="string" value="gnome-system-monitor"/>
+ <property name="&lt;Alt&gt;&lt;Super&gt;t" type="string" value="amdgpu-toggle-tearfree-x11"/>
</property>
</property>
<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 @@
+#!/bin/sh
+
+# requires: xrandr, awk
+
+err() {
+ printf "%s\n" "$*" >&2
+ exit 1
+}
+
+for cmd in xrandr awk; do
+ command -v "$cmd" >/dev/null 2>&1 || err "required command not found: $cmd"
+done
+
+# collect all connected outputs
+outputs=$(xrandr --query | awk '/ connected/ { print $1 }')
+
+[ -n "$outputs" ] || err "no connected outputs found."
+
+# sample TearFree state from the first connected output
+first_output=$(printf '%s\n' "$outputs" | awk 'NR==1')
+current_state=$(xrandr --props | awk -v out="$first_output" '
+ $1 == out { found=1 }
+ found && /TearFree:/ { print $2; exit }
+')
+
+case "$current_state" in
+ on) new_state="off" ;;
+ *) new_state="on" ;;
+esac
+
+# single xrandr invocation, avoids monitor reconfiguration for the most part
+xrandr_args=""
+for output in $outputs; do
+ xrandr_args="$xrandr_args --output $output --set TearFree $new_state"
+done
+
+# shellcheck disable=SC2086
+xrandr $xrandr_args || err "failed to set TearFree $new_state on all outputs"
+
+notify-send "AMDGPU (X11)" "TearFree $new_state" -t 3072 \
+ || printf "TearFree toggled to '%s' on all connected outputs.\n" "$new_state"