add: sticky-notes and bspwm scripts
This commit is contained in:
parent
212028fcd0
commit
d0a680305c
6 changed files with 146 additions and 6 deletions
|
@ -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 &
|
||||
|
|
26
.config/bspwm/external_rules
Executable file
26
.config/bspwm/external_rules
Executable file
|
@ -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"
|
93
.config/bspwm/swallow.py
Executable file
93
.config/bspwm/swallow.py
Executable file
|
@ -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()
|
|
@ -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
|
||||
|
|
8
.local/bin/sticky-note
Executable file
8
.local/bin/sticky-note
Executable file
|
@ -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"
|
BIN
.local/share/fonts/PermanentMarker.ttf
Normal file
BIN
.local/share/fonts/PermanentMarker.ttf
Normal file
Binary file not shown.
Loading…
Reference in a new issue