diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index 6a843b8..52730ea 100755 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -8,7 +8,7 @@ if [[ $host_name == "portalo" ]]; then bspc monitor DVI-D-1 -d side-view voip messenger bspc desktop ^7 --layout monocle - bspc desktop ^9 --layout monocle + #bspc desktop ^9 --layout monocle bspc desktop ^10 --layout monocle elif [[ $host_name == *"laptop"* ]]; then bspc monitor eDP1 -d web terminal 3 4 5 6 7 8 9 10 @@ -27,15 +27,22 @@ bspc config gapless_monocle true bspc config focus_follows_pointer true +bspc config automatic_scheme alternate + +bspc config external_rules_command "$HOME/.config/bspwm/external_rules" + bspc rule -a 'firefox' desktop='web' bspc rule -a 'firefox:Toolkit' follow='true' desktop='side-view' state='fullscreen' -bspc rule -a 'TeamSpeak 3' desktop='voip' +bspc rule -a 'TeamSpeak 3' desktop='voip' locked='true' +bspc rule -a 'Alacritty:mail' desktop='voip' locked='true' split_ratio='0.47' +bspc rule -a 'Riot' desktop='voip' locked='true' bspc rule -a 'discord' desktop='voip' bspc rule -a 'Evolution' desktop='messenger' -bspc rule -a 'Riot' desktop='messenger' -bspc rule -a 'Signal' desktop='messenger' follow='true' -bspc rule -a 'Steam' desktop='game' +bspc rule -a 'Signal' desktop='messenger' locked='true' +#bspc rule -a 'Steam' desktop='game' bspc rule -a 'Zathura' state='tiled' -bspc rule -a 'Alacritty' desktop='messenger' +bspc rule -a 'Guitarix:guitarix' desktop='messenger' +bspc rule -a 'Alacritty:sticky-note' state=floating sticky=on border=off $HOME/.config/polybar/launch.sh & +$HOME/.config/bspwm/swallow.py & diff --git a/.config/bspwm/external_rules b/.config/bspwm/external_rules new file mode 100755 index 0000000..ae5e675 --- /dev/null +++ b/.config/bspwm/external_rules @@ -0,0 +1,26 @@ +#!/usr/bin/sh + +wid=$1 +class=$2 +instance=$3 +consequences=$4 + +#notify-send "$1 $2 $3 $4" + +#if [ "$instance" = fontforge ] ; then +# title=$(xtitle "$wid") +# case "$title" in +# Layers|Tools|Warning) +# echo "focus=off" +# ;; +# esac +#fi +# +#case "$class" in +# Lutris|Liferea) +# eval "$consequences" +# [ "$state" ] || echo "state=pseudo_tiled" +# ;; +#esac + +#echo "state=floating" diff --git a/.config/bspwm/swallow.py b/.config/bspwm/swallow.py new file mode 100755 index 0000000..8d84cc4 --- /dev/null +++ b/.config/bspwm/swallow.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +import subprocess +from functools import partial + + +cmd_run = partial(subprocess.Popen, text=True, shell=True) + + +def cmd_output(cmd): + try: + out = subprocess.check_output(cmd, text=True, shell=True).strip() + except Exception: + out = '' + return out + + +def execute(cmd): + popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, + universal_newlines=True, text=True, shell=True) + for stdout_line in iter(popen.stdout.readline, ""): + yield stdout_line + popen.stdout.close() + return_code = popen.wait() + if return_code: + raise subprocess.CalledProcessError(return_code, cmd) + + +def is_fullscreen(wid): + return cmd_output(f'bspc query -N -n {wid}.fullscreen').strip() + + +def is_floating(wid): + return cmd_output(f'bspc query -N -n {wid}.floating').strip() + + +def get_class(wid): + out = cmd_output(f'xprop -id {wid} | grep WM_CLASS') + if out: + out = out.split(' = ')[1].split(', ') + return (out[0].strip('"'), out[1].strip('"')) + else: + return '' + + +def get_pid(wid): + out = cmd_output(f'xprop -id {wid} | grep WM_PID') + if out: + return out.split(' = ')[1] + else: + return '' + + +def is_child(pid, child_pid): + tree = cmd_output(f'pstree -T -p {pid}') + for line in tree.split('\n'): + if child_pid in line: + return True + return False + + +def swallow(): + swallowed = {} + for event in execute('bspc subscribe node'): + event = event.split() + if event[0] == 'node_add': + new_wid = event[-1] + last_wid = cmd_output('bspc query -N -d -n last.window') + if(get_class(last_wid)[0] != 'Alacritty'): + continue + if any([is_floating(new_wid), is_floating(last_wid), + is_fullscreen(new_wid), is_fullscreen(last_wid)]): + continue + new_pid = get_pid(new_wid) + last_pid = get_pid(last_wid) + if not all([new_pid, last_pid]): + continue + if is_child(last_pid, new_pid): + cmd_run(f'bspc node --swap {last_wid} --follow') + cmd_run(f'bspc node {new_wid} --flag private=on') + cmd_run(f'bspc node {last_wid} --flag hidden=on') + cmd_run(f'bspc node {last_wid} --flag private=on') + swallowed[new_wid] = last_wid + if event[0] == 'node_remove': + removed_wid = event[-1] + if removed_wid in swallowed.keys(): + swallowed_id = swallowed[removed_wid] + cmd_run(f'bspc node {swallowed_id} --flag hidden=off') + cmd_run(f'bspc node --focus {swallowed_id}') + + +if __name__ == '__main__': + swallow() diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index fbd7dfa..050d93c 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -53,3 +53,9 @@ bindkey '^e' edit-command-line # Load zsh-syntax-highlighting; should be last. source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null + +if [[ $STICKY_NOTE ]]; then + PS1= + cat "/tmp/sticky-note" + return +fi diff --git a/.local/bin/sticky-note b/.local/bin/sticky-note new file mode 100755 index 0000000..d0fcb6a --- /dev/null +++ b/.local/bin/sticky-note @@ -0,0 +1,8 @@ +#!/bin/bash + +CONFIG_FILE="$HOME/.config/alacritty/sticky-notes.yml" +STICKY_NOTE_FILE="/tmp/sticky-note" + +echo "$@" > "$STICKY_NOTE_FILE" + +alacritty --config-file "$CONFIG_FILE" diff --git a/.local/share/fonts/PermanentMarker.ttf b/.local/share/fonts/PermanentMarker.ttf new file mode 100644 index 0000000..8052508 Binary files /dev/null and b/.local/share/fonts/PermanentMarker.ttf differ