Created
September 29, 2019 19:08
-
-
Save jimenezrick/6f01cf8e23f5c473ab8295d25a1d97de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
bspc monitor -d $(seq 1 9) | |
bspc config top_padding 14 | |
bspc config focused_border_color "#00ccff" | |
bspc config normal_border_color "#cccccc" | |
bspc config border_width 1 | |
bspc config window_gap 0 | |
bspc config split_ratio 0.5 | |
bspc config borderless_monocle true | |
bspc config gapless_monocle true | |
bspc config focus_follows_pointer true | |
bspc config pointer_modifier mod1 | |
bspc config pointer_action1 move | |
bspc config pointer_action2 resize_side | |
bspc config pointer_action3 resize_corner | |
bspc rule -a Emacs state=tiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import time | |
def get_color(name): | |
return os.getenv(name) | |
def format_field(text, fg, bg): | |
return "%{{F{0}}}%{{B{1}}} {2} %{{B-}}%{{F-}}".format(get_color(fg), get_color(bg), text) | |
def format_action(text, command): | |
return "%{{A:{}:}}{}%{{A}}".format(command, text) | |
def format_wmstatus(items): | |
color = { | |
'M': ("PANEL_COLOR_FOCUSED_MONITOR_FG", "PANEL_COLOR_FOCUSED_MONITOR_BG"), | |
'm': ("PANEL_COLOR_MONITOR_FG", "PANEL_COLOR_MONITOR_BG"), | |
'O': ('PANEL_COLOR_FOCUSED_OCCUPIED_FG', 'PANEL_COLOR_FOCUSED_OCCUPIED_BG'), | |
'o': ('PANEL_COLOR_OCCUPIED_FG', 'PANEL_COLOR_OCCUPIED_BG'), | |
'F': ('PANEL_COLOR_FOCUSED_FREE_FG', 'PANEL_COLOR_FOCUSED_FREE_BG'), | |
'f': ('PANEL_COLOR_FREE_FG', 'PANEL_COLOR_FREE_BG'), | |
'U': ('PANEL_COLOR_FOCUSED_URGENT_FG', 'PANEL_COLOR_FOCUSED_URGENT_BG'), | |
'u': ('PANEL_COLOR_URGENT_FG', 'PANEL_COLOR_URGENT_BG'), | |
'L': ('PANEL_COLOR_STATE_FG', 'PANEL_COLOR_STATE_BG'), | |
'T': ('PANEL_COLOR_STATE_FG', 'PANEL_COLOR_STATE_BG'), | |
'G': ('PANEL_COLOR_STATE_FG', 'PANEL_COLOR_STATE_BG'), | |
} | |
layout, state, flags = None, None, None | |
focused_monitor = True | |
output = [] | |
for item in items: | |
t = item[0] if focused_monitor else item[0].lower() | |
v = item[1:] | |
if t in "Mm": | |
focused_monitor = t == 'M' | |
f = format_action(v, "bspc monitor -f {}".format(v)) | |
output.append(format_field(f, color[t][0], color[t][1])) | |
elif t == "L": | |
layout = v | |
elif t == "T": | |
state = v | |
elif t == "G": | |
f = "{}:{}".format(layout, state) | |
flags = v | |
if flags != "": | |
f += ":{}".format(flags) | |
output.append(format_field(f, color[t][0], color[t][1])) | |
else: | |
f = format_action(v, "bspc desktop -f {}".format(v)) | |
output.append(format_field(f, color[t][0], color[t][1])) | |
return ''.join(output) | |
def format_status(state, color, notify=False): | |
system=format_field(state["system"], color["system"][0], color["system"][1]) | |
notification=format_field(state["notification"], color["notification"][0], color["notification"][1]) | |
return "%{{l}}{wmstatus}%{{c}}{title}%{{r}}{system}".format( | |
wmstatus=format_wmstatus(state["wmstatus"]), | |
title=format_field(state["title"], color["title"][0], color["title"][1]), | |
system=notification if notify else system, | |
) | |
def send_status(status): | |
print(status, flush=True) | |
if __name__ == "__main__": | |
state = { | |
"wmstatus": [], | |
"title": "", | |
"system": "", | |
"notification": None, | |
} | |
while True: | |
cmd = sys.stdin.readline().rstrip("\n") | |
if cmd.startswith("W"): | |
arg = cmd[1:].split(":") | |
cmd = "wmstatus" | |
else: | |
i = cmd.index(' ') | |
arg = cmd[i+1:] | |
cmd = cmd[:i] | |
state[cmd] = arg | |
color = { | |
"title": ("PANEL_COLOR_TITLE_FG", "PANEL_COLOR_TITLE_BG"), | |
"system": ("PANEL_COLOR_SYS_FG", "PANEL_COLOR_SYS_BG"), | |
"notification": ("PANEL_COLOR_SYS_BG", "PANEL_COLOR_SYS_FG"), | |
} | |
if state["notification"] is not None: | |
send_status(format_status(state, color, notify=True)) | |
state["notification"] = None | |
time.sleep(10) | |
else: | |
send_status(format_status(state, color)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# wm independent hotkeys | |
# | |
# terminal emulator | |
alt + Return | |
alacritty | |
alt + shift + Return | |
urxvt | |
# program launcher | |
alt + p | |
dmenu_run -fn "xos4 Terminus:pixelsize=12" | |
# selected programs launcher | |
alt + o | |
selectcmd.sh -fn "xos4 Terminus:pixelsize=12" | |
# screen locker | |
alt + u | |
slock | |
# make sxhkd reload its configuration files: | |
alt + Escape | |
pkill -USR1 -x sxhkd | |
# | |
# bspwm hotkeys | |
# | |
# quit/restart bspwm | |
alt + {q,r} | |
bspc {quit,wm -r} | |
# close and kill | |
alt + {_,shift + }w | |
bspc node -{c,k} | |
# alternate between the tiled and monocle layout | |
alt + m | |
bspc desktop -l next | |
# send the newest marked node to the newest preselected node | |
alt + y | |
bspc node newest.marked.local -n newest.!automatic.local | |
# swap the current node and the biggest node | |
alt + g | |
bspc node -s biggest | |
# | |
# state/flags | |
# | |
alt + space | |
bspc node -t "~"{floating,tiled} | |
# set the window state | |
alt + {t,shift + t,s,f} | |
bspc node -t {tiled,pseudo_tiled,floating,fullscreen} | |
# set the node flags | |
alt + ctrl + {m,x,y,z} | |
bspc node -g {marked,locked,sticky,private} | |
# | |
# focus/swap | |
# | |
# focus the node in the given direction | |
alt + {_,shift + }{h,j,k,l} | |
bspc node -{f,s} {west,south,north,east} | |
# focus the node for the given path jump | |
alt + {p,b,comma,period} | |
bspc node -f @{parent,brother,first,second} | |
# focus the next/previous node in the current desktop | |
alt + {_,shift + }c | |
bspc node -f {next,prev}.local | |
# focus the next/previous desktop in the current monitor | |
alt + bracket{left,right} | |
bspc desktop -f {prev,next}.local | |
# focus the last node/desktop | |
alt + {grave,Tab} | |
bspc {node,desktop} -f last | |
# focus the older or newer node in the focus history | |
alt + {o,i} | |
bspc wm -h off; \ | |
bspc node {older,newer} -f; \ | |
bspc wm -h on | |
# focus or send to the given desktop | |
alt + {_,shift + }{1-9,0} | |
bspc {desktop -f,node -d} '^{1-9,10}' | |
# | |
# preselect | |
# | |
# preselect the direction | |
alt + ctrl + {h,j,k,l} | |
bspc node -p {west,south,north,east} | |
# preselect the ratio | |
alt + ctrl + {1-9} | |
bspc node -o 0.{1-9} | |
# cancel the preselection for the focused node | |
alt + ctrl + space | |
bspc node -p cancel | |
# cancel the preselection for the focused desktop | |
alt + ctrl + shift + space | |
bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel | |
# | |
# move/resize | |
# | |
# expand a window by moving one of its side outward | |
alt + {h,j,k,l} | |
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} | |
# contract a window by moving one of its side inward | |
alt + shift + {h,j,k,l} | |
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} | |
# move a floating window | |
alt + {Left,Down,Up,Right} | |
bspc node -v {-20 0,0 20,0 -20,20 0} | |
# rotate node | |
alt + {_,shift + }R | |
bspc node @parent -R {90,-90} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set_up_X() { | |
export PATH=~/bin:$PATH | |
setxkbmap -option ctrl:nocaps | |
xmodmap ~/.Xmodmaprc | |
xset r rate 150 60 | |
} | |
set_background() { | |
if [ -d ~/.wallpapers ] | |
then | |
random-wallpaper.sh | |
else | |
xsetroot -grey | |
fi | |
} | |
show_new_emails() { | |
local count=$(mpop --status-only | awk '/^new:/ { print $2 }') | |
while true | |
do | |
local new_count=$(mpop --status-only | awk '/^new:/ { print $2 }') | |
if [[ $new_count > $count ]] | |
then | |
count=$new_count | |
echo 'notification New mail' >$PANEL_FIFO | |
elif [[ $new_count < $count ]] | |
then | |
count=$new_count | |
fi | |
sleep 10m | |
done | |
} | |
panel_status() { | |
until bspc subscribe report -c 1 &>/dev/null | |
do | |
sleep 0.5 | |
done | |
bspc subscribe report >$PANEL_FIFO & | |
xtitle -sf 'title %s\n' >$PANEL_FIFO & | |
while date '+system %a %H:%M:%S' >$PANEL_FIFO | |
do | |
sleep 1 | |
done & | |
wid=$(xdo id -m -a $PANEL_WM_NAME) | |
xdo above -t "$(xdo id -N Bspwm -n root | sort | head -1)" "$wid" | |
} | |
panel() { | |
~/.config/bspwm/panel_status.py <$PANEL_FIFO | \ | |
lemonbar -n $PANEL_WM_NAME \ | |
-g x$PANEL_HEIGHT \ | |
-f "$PANEL_FONT" \ | |
-F "$PANEL_COLOR_DEFAULT_FG" \ | |
-B "$PANEL_COLOR_DEFAULT_BG" | \ | |
sh | |
} | |
set_up_X & | |
set_background & | |
# XXX | |
# (restart dwmstatus -i $(ip route | awk '/^default/ { print $5 }')) & | |
# XXX | |
( | |
source ~/.config/bspwm/panel.conf | |
source ~/.config/bspwm/panel_colors.conf | |
if [ ! -e $PANEL_FIFO ] | |
then | |
mkfifo $PANEL_FIFO | |
fi | |
panel & | |
panel_status & | |
show_new_emails & | |
) | |
sxhkd & | |
exec bspwm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment