From e11cef88d292d6cf8f7431312cb937cfd4c7ccbc Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Thu, 2 May 2024 16:14:28 -0600 Subject: [PATCH] Sway: improve gap toggling --- sway/config | 7 ++++--- sway/toggle_gaps.py | 29 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/sway/config b/sway/config index 9f36e63..92ddb80 100644 --- a/sway/config +++ b/sway/config @@ -55,6 +55,8 @@ set $screenshot_sound ffplay -nodisp -autoexit -v error ~/.config/sway/screensho set $screenshot_tmp /dev/shm/screenshot_shm.png set $screenshot_script ~/.configs_pointer/bin/screenshot_wayland.py +set $toggle_gaps ~/.configs_pointer/sway/toggle_gaps.py + #╔─────────────────────────────────────────────────────────────────────────────╗ #│ Pαηεs αηd cδηταiηεrs | #╚─────────────────────────────────────────────────────────────────────────────╝ @@ -136,8 +138,7 @@ bindsym $mod2+bracketright gaps inner current minus 3 bindsym $mod2+bracketleft gaps inner current plus 3 #bindsym $mod2+equal gaps toggle # Standard outer gapping for 27" screen -bindsym $mod2+c gaps vertical current set 100, \ - gaps horizontal current set 200 +bindsym $mod2+c exec $toggle_gaps toggle 100 200 # Same as above, shifted left slightly bindsym $mod2+g gaps vertical current set 100, \ gaps left current set 150, \ @@ -288,7 +289,7 @@ floating_modifier $mod1 normal # Screenlock bindsym $mod2+i exec ~/.config/sway/brightness_lock.sh # Screen kill (turns off display output, but keeps virtual display active) -bindsym --locked $mod2+u output * power toggle +bindsym --locked $mod2+u output DP-1 power toggle # Scratchpad bindsym $mod1+Shift+minus move scratchpad bindsym $mod1+minus scratchpad show diff --git a/sway/toggle_gaps.py b/sway/toggle_gaps.py index 8356990..3e70d73 100755 --- a/sway/toggle_gaps.py +++ b/sway/toggle_gaps.py @@ -33,19 +33,24 @@ def has_gaps(workspace): def swaymsg_gaps(v, h, is_all): - for x, n in [[v, "vertical"], [h, "horizontal"]]: - swaymsg = subprocess.Popen( - [ - "swaymsg", - "gaps", - n, - "all" if is_all else "current", - "set", - str(x), - ] - ) + swaymsg = subprocess.Popen( + [ + "swaymsg", + "gaps", + "vertical", + "all" if is_all else "current", + "set", + str(v), + ",", + "gaps", + "horizontal", + "all" if is_all else "current", + "set", + str(h) + ] + ) - swaymsg.communicate(1) + swaymsg.communicate(1) def toggle_workspace(ws, v, h):