diff options
Diffstat (limited to 'bspwm')
| -rwxr-xr-x | bspwm/bspwmrc | 35 | ||||
| -rw-r--r-- | bspwm/sxhkdrc | 54 | ||||
| -rw-r--r-- | bspwm/terminal.py | 46 | ||||
| -rwxr-xr-x | bspwm/terminal.sh | 16 |
4 files changed, 128 insertions, 23 deletions
diff --git a/bspwm/bspwmrc b/bspwm/bspwmrc index 26c534c..f6d3a99 100755 --- a/bspwm/bspwmrc +++ b/bspwm/bspwmrc @@ -1,30 +1,19 @@ -#!/bin/bash +#!/bin/sh -sxhkd -c ~/.config/sxhkd/sxhkdrc.bspwm & +sxhkd -c ~/.config/bspwm/sxhkdrc & ~/.config/polybar/launch.sh & bspc monitor primary -d 1 2 3 4 term - -python <<EOF -import subprocess -import sys -p = subprocess.run(['xrandr', '--listactivemonitors'], - capture_output=True, check=True) -count = int(p.stdout.decode('utf-8').split('\n')[0].split(':')[1]) -if count < 2: - sys.exit(1) -EOF -[ $? -eq 0 ] && bspc monitor primary#next -d a s d f - -bspc config border_width 4 -bspc config window_gap 5 - -bspc config focus_follows_pointer true -bspc config pointer_follows_monitor true - -bspc config split_ratio 0.52 -bspc config borderless_monocle true -bspc config gapless_monocle true +[ $(xrandr --listactivemonitors | wc -l) -gt 2 ] && \ + bspc monitor primary#next -d a s d f + +bspc config border_width 4 +bspc config window_gap 0 +bspc config focus_follows_pointer true +bspc config pointer_follows_monitor true +bspc config split_ratio 0.52 +bspc config borderless_monocle true +bspc config gapless_monocle true bspc rule -a *:tmux_term desktop=term diff --git a/bspwm/sxhkdrc b/bspwm/sxhkdrc new file mode 100644 index 0000000..3837ab3 --- /dev/null +++ b/bspwm/sxhkdrc @@ -0,0 +1,54 @@ +F12 + ~/.config/bspwm/terminal.sh + +mod4 + Return + alacritty +mod4 + space + rofi -show drun +#mod4 + backslash +# i3-msg "split h" +#mod4 + minus +# i3-msg "split v" +#mod4 + Tab +# i3-msg "layout toggle split" +#mod4 + p +# i3-msg "focus parent" +#mod4 + r +# i3-msg "mode resize" + + +mod4 + {1, 2, 3, 4, a, s, d, f} + bspc desktop -f {1, 2, 3, 4, a, s, d, f} + +mod4 + shift + {1, 2, 3, 4, a, s, d, f} + bspc node -d {1, 2, 3, 4, a, s, d, f} + + +mod4 + shift + r + bspc wm -r +mod4 + shift + e + bspc quit +mod4 + shift + q + bspc node -c +mod4 + shift + space + bspc node -t ~floating +mod4 + shift + Return + bspc node -t ~fullscreen + +mod4 + {h, Left} + bspc node -f west +mod4 + {j, Down} + bspc node -f south +mod4 + {k, Up} + bspc node -f north +mod4 + {l, Right} + bspc node -f east + +mod4 + shift + {h, Left} + bspc node -s west +mod4 + shift + {j, Down} + bspc node -s west +mod4 + shift + {k, Up} + bspc node -s west +mod4 + shift + {l, Right} + bspc node -s west diff --git a/bspwm/terminal.py b/bspwm/terminal.py new file mode 100644 index 0000000..eee7875 --- /dev/null +++ b/bspwm/terminal.py @@ -0,0 +1,46 @@ +import subprocess + + +desktop_name = 'term' +instance_name = 'tmux_term' + + +def is_term_running(): + p = subprocess.run(['xdo', 'id', '-n', instance_name]) + return p.returncode == 0 + + +def run_term(): + subprocess.Popen(['alacritty', '--class', instance_name, + '-e', 'tmux', 'new-session', '-A', '-s', 'default']) + + +def get_focused_desktop(): + p = subprocess.run(['bspc', 'query', '-D', '--names', '-d', 'focused'], + capture_output=True, + check=True) + return p.stdout.decode('utf-8').strip() + + +def hide_term(): + subprocess.run(['bspc', 'desktop', '-f', 'last.local'], check=True) + + +def show_term(): + subprocess.run(['bspc', 'desktop', 'term', '-m', 'focused']) + subprocess.run(['bspc', 'desktop', '-f', 'term'], check=True) + + +def main(): + if not is_term_running(): + run_term() + + focused_desktop = get_focused_desktop() + if focused_desktop == desktop_name: + hide_term() + else: + show_term() + + +if __name__ == '__main__': + main() diff --git a/bspwm/terminal.sh b/bspwm/terminal.sh new file mode 100755 index 0000000..8cd5418 --- /dev/null +++ b/bspwm/terminal.sh @@ -0,0 +1,16 @@ + + +DESKTOP=term +INSTANCE=tmux_term + +(xdo id -n $INSTANCE > /dev/null) || \ + alacritty --class $INSTANCE -e \ + tmux new-session -A -s default + +if [ $(bspc query -D --names -d focused) = $DESKTOP ]; then + echo "sakrit" + bspc desktop -f last.local +else + bspc desktop $DESKTOP -m focused + bspc desktop -f $DESKTOP +fi |
