Commit 156de53b authored by Guilherme Semente's avatar Guilherme Semente 🌱

Add bspwm helper

parent 78326cff
......@@ -18,20 +18,37 @@ shift + super + r
# applications
#
# terminal
# scratch terminal
super + Return
gnome-terminal -e "tmux new-session -A -s 0"
bspwm-scratch "bspwm-scratch-term" "state=floating border=off sticky=on" \
${BSPWM_SCRATCH_TERM_COMMAND}
super + {0-9}
gnome-terminal -e "tmux new-session -A -s {0-9}"
bspc rule -a \* -o state=tiled && st -f "Monoid-14" -e tmux new-session -A -s {0-9}
# quick launch
super + semicolon ; {e,f,t}
{emacsclient -a="" -c,firefox,st -f monoid-14}
bspc rule -a \* -o state=tiled && {emacsclient -a="" -c,firefox,st -f "Monoid-14"}
# rofi launcher
super + space
rofi -modi combi -show combi -combi-modi run,drun,window,ssh
# calc
super + F5
bspwm-scratch "bspwm-scratch-calc" "state=floating border=off sticky=on" \
st -c "bspwm-scratch-calc" -g "16x12" -f Monoid-24 -e bc -q
# translator
super + F8
bspc rule -a \* -o state=floating && \
st -g "70x20" -f "Monoid-14" -e bash -c "torsocks trans -b -t pt '$(xclip -o)' && read"
# telegram
super + F9
bspwm-scratch "TelegramDesktop" "state=floating border=off sticky=on" \
flatpak run org.telegram.desktop || flatpak run org.telegram.desktop
# lock screen
super + shift + l
......
#!/bin/bash
## bspwm-scratch ---
#
# SYNOPSIS
#
# bspwm-scratch CLASS-NAME RULE COMMAND
#
# EXAMPLE
#
# For a classic scratchpad terminal use the following sxhkd hotkey:
#
# super + Return
# bspwm-scratch scratch-term "state=floating sticky=on" \
# stterm -c scratch-term -e tmux new -s scratch
#
# Another example:
#
# super + F12
# bspwm-scratch transmission-gtk "state=floating sticky=on" \
# transmission-gtk
#
# And, optionally, the following bspwm configuration:
#
# # hide scratch windows when they are not focused
# SCRATCH_CLASS_PATTERN="scratch-term|transmission-gtk"
# bspc subscribe desktop_focus node_focus | while read -a msg; do
# _focused_xid=$(xdotool getwindowfocus)
# _scratch_xids=$(xdotool search --onlyvisible --class "$SCRATCH_CLASS_PATTERN")
# case "${msg[0]}" in
# desktop_focus)
# # hide scratch window on desktop changes
# echo "$scratch_xids" | xargs -rI{} bspc node "{}" --flag hidden=on
# ;;
# node_focus)
# # hide scratch window when it lose focus
# for scratch_xid in $scratch_xids; do
# [ "${focused_xid:-nil}" != "${scratch_xid:-nil}" ] \
# && bspc node "$scratch_xid" --flag hidden=on
# done
# ;;
# esac
# done &
# unset _focused_xid _scratch_xid _scratch_xids
#
# exit on first error
set -e
# exit when an undefined variable is accessed
set -u
function main() {
local classname command xids
classname="$1"
rule="$2"
command="${*:3}"
xids=$(xdotool search --class "$classname" || true)
if [ -n "$xids" ]; then
# toggle window
echo "$xids" | xargs -rI{} bspc node "{}" --flag hidden --focus
else
# first run
bspc rule -l | grep -q "^${classname}:" || bspc rule -a "$classname" "$rule"
# shellcheck disable=SC2086
exec $command
fi
}
main "$@"
......@@ -20,6 +20,7 @@ export X_WALLPAPER="${X_WALLPAPER:-#222222}"
export BSPWM_BORDER_COLOR="${BSPWM_BORDER_COLOR:-#888888}"
export BSPWM_FOCUSED_COLOR="${BSPWM_FOCUSED_COLOR:-#FFFFFF}"
export BSPWM_PRESEL_COLOR="${BSPWM_PRESEL_COLOR:-$BSPWM_FOCUSED_COLOR}"
export BSPWM_SCRATCH_TERM_COMMAND
# xautolock
export X_LOCKTIME="${X_LOCKTIME:-8}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment