Add bspwm config

This commit is contained in:
Ian Adam Naval 2014-10-21 00:41:40 -04:00
parent 2276485f37
commit 91fe4c1c80
3 changed files with 240 additions and 0 deletions

View File

@ -0,0 +1,112 @@
#!/usr/bin/env python
import json
import subprocess
import sys
import threading
from queue import Queue
def format_color(text, color):
color = color.replace("#", "#ff")
return r"%{F" + color + r"}" + text + r"%{F-}"
def format_output(datum):
text = datum['full_text']
if 'color' in datum:
text = format_color(text, datum['color'])
return text
def send_output(text):
print(text)
def process_status(q):
status = subprocess.Popen(
["python", "/home/ian/.i3/status.py"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
# get the version and newline
for i in range(2):
status.stdout.readline()
# continue to process each line
while not status.stdout.closed:
line = status.stdout.readline().decode("utf-8")
if line.startswith(','):
line = line[1:]
center = []
right = []
data = json.loads(line)
for datum in data:
if 'Clock' in datum['name']:
center.append(format_output(datum))
else:
right.append(format_output(datum))
separator = ' | '
q.put_nowait(("", separator.join(center), separator.join(right)))
def process_bspwm(q):
bspwm = subprocess.Popen(
["bspc", "control", "--subscribe"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
# continue to process each line
while not bspwm.stdout.closed:
line = bspwm.stdout.readline().decode("utf-8")
left = []
desktops = line.strip().split(':')
# ignore first and last bit from bspc output
desktops = desktops[1:len(desktops) - 1]
for i, desktop in enumerate(desktops):
if desktop.startswith('o'):
left.append(
"%{{A:bspc desktop -f ^{i}:}}[{i}]%{{A}}".format(i=i + 1))
elif desktop.startswith('O') or desktop.startswith('F'):
left.append(
("%{{F#fff92672}}"
"%{{A:bspc desktop -f ^{i}:}}[{i}]%{{A}}"
"%{{F-}}").format(i=i + 1))
# elif desktop.startswith('f'):
# left.append("[{}]".format(i))
q.put_nowait((''.join(left), "", ""))
def get_output():
left = ""
center = ""
right = ""
q = Queue()
status_thread = threading.Thread(target=process_status, args=[q])
status_thread.start()
bspwm_thread = threading.Thread(target=process_bspwm, args=[q])
bspwm_thread.start()
while True:
new_left, new_center, new_right = q.get()
if new_left:
left = new_left
if new_center:
center = new_center
if new_right:
right = new_right
yield left, center, right
def main():
for left, center, right in get_output():
output = '%{{l}} {} %{{c}} {} %{{r}} {}'.format(left, center, right)
send_output(output)
# sys.stderr.write(output + '\n')
sys.stderr.flush()
sys.stdout.flush()
if __name__ == '__main__':
main()

25
bspwm/bspwm.configdir/bspwmrc Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
bspc config border_width 1
bspc config window_gap 8
bspc config top_padding 20
bspc config split_ratio 0.52
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config focus_by_distance true
bspc config focus_follows_pointer true
bspc monitor -d I II III IV V VI VII VIII IX X
bspc rule -a Gimp desktop=^8 follow=on floating=on
bspc rule -a mplayer2 floating=on
bspc rule -a python2 floating=on
bspc rule -a Kupfer.py focus=on
bspc rule -a Screenkey manage=off
pgrep bar | xargs kill -9
ps aux | grep "status.py" | awk '{print $2}' | xargs kill -9
ps aux | grep "bar" | awk '{print $2}' | xargs kill -9
(python $HOME/.config/bspwm/bar.py | bar -g x20 -B '#ff252525' -F '#fff9f8f5' -f "Meslo LG L DZ" &)

View File

@ -0,0 +1,103 @@
#
# bspwm hotkeys
#
super + alt + Escape
bspc quit
super + w
bspc window -c
super + t
bspc desktop -l next
super + b
bspc desktop -B
super + {s,f}
bspc window -t {floating,fullscreen}
super + {grave,Tab}
bspc {window,desktop} -f last
super + apostrophe
bspc window -s last
super + {o,i}
bspc control --record-history off; \
bspc window {older,newer} -f; \
bspc control --record-history on
super + y
bspc window -w last.manual
super + m
bspc window -s biggest
super + {_,shift + }{Left,Down,Up,Right}
bspc window -{f,s} {left,down,up,right}
super + {_,shift + }c
bspc window -f {next,prev}
super + {comma,period}
bspc desktop -C {backward,forward}
super + bracket{left,right}
bspc desktop -f {prev,next}
super + ctrl + {Left,Down,Up,Right}
bspc window -p {left,down,up,right}
super + {-,\}
bspc window -p {down,right}
super + ctrl + {_,shift + }space
bspc {window -p cancel,desktop -c}
super + alt + {Left,Down,Up,Right}
bspc window -e {left -10,down +10,up -10,right +10}
super + alt + shift + {Left,Down,Up,Right}
bspc window -e {right -10,up +10,down -10,left +10}
super + ctrl + {1-9}
bspc window -r 0.{1-9}
super + {_,shift + }{1-9,0}
bspc {desktop -f,window -d} ^{1-9,10}
~button1
bspc pointer -g focus
super + button{1-3}
bspc pointer -g {move,resize_side,resize_corner}
super + !button{1-3}
bspc pointer -t %i %i
super + @button{1-3}
bspc pointer -u
#
# wm independent hotkeys
#
super + Return
terminator
super + shift + Return
xterm
super + d
j4-dmenu-desktop --dmenu="dmenu -i -sb '#800' -nb '#252525' -fn 'Meslo LG L DZ-8'"
# make sxhkd reload its configuration files:
super + Escape
pkill -USR1 -x sxhkd
super + shift + R
~/.config/bspwm/bspwmrc
Print
gnome-screenshot -i