diff options
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/.config/i3/config | 3 | ||||
| -rwxr-xr-x | misc/.config/i3/focus.sh | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/misc/.config/i3/config b/misc/.config/i3/config index 803dcd1..38ab273 100644 --- a/misc/.config/i3/config +++ b/misc/.config/i3/config @@ -207,7 +207,10 @@ bindsym $mod+Shift+m focus parent; fullscreen; focus child bindsym $mod+equal exec dunstctl history-pop bindsym $mod+minus exec dunstctl close +bindsym $mod+F1 exec --no-startup-id ~/.config/i3/focus.sh + # startup +exec --no-startup-id xsetroot -solid "#000000" exec ibus-daemon exec redshift-gtk exec --no-startup-id i3-msg 'workspace $ws1; exec urxvt' diff --git a/misc/.config/i3/focus.sh b/misc/.config/i3/focus.sh new file mode 100755 index 0000000..6dd7d46 --- /dev/null +++ b/misc/.config/i3/focus.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# toggle reading/focus mode on the current workspace + +WIDTH=1000 # desired window width in pixels + +ws=$(i3-msg -t get_tree | jq -c 'first(.. | objects + | select(.type=="workspace" and any(.. | objects; .focused == true)))') + +# Gap per side = (workspace width - desired width) / 2, minus any inner gap +ws_width=$(echo "$ws" | jq '.rect.width') +inner_gap=$(echo "$ws" | jq '.gaps.inner // 0') +gap=$(( (ws_width - WIDTH) / 2 - inner_gap )) +[ "$gap" -lt 0 ] && gap=0 + +on="layout tabbed; gaps horizontal current set $gap; bar mode hide" +off="layout splith; gaps horizontal current set 0; bar mode dock" + +count=$(echo "$ws" | jq '.nodes | length') +inner=$(echo "$ws" | jq '.nodes[0].nodes | length') + +if [ "$count" -eq 1 ] && [ "$inner" -gt 0 ]; then + layout=$(echo "$ws" | jq -r '.nodes[0].layout') + child=$(echo "$ws" | jq '.nodes[0].nodes[0].id') + if [ "$layout" = "tabbed" ]; then + i3-msg "[con_id=$child] $off" + else + i3-msg "[con_id=$child] $on" + fi +else + child=$(echo "$ws" | jq '.nodes[0].id') + i3-msg "[con_id=$child] $on" +fi |
