This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
62 additions
and
111 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
id=$1 | ||
class=$2 | ||
|
||
name=$(xprop -id "$id" WM_NAME) | ||
name=${name#*\"} | ||
name=${name%\"} | ||
|
||
if [[ $(bspc query -N -n focused.automatic) ]] ; then | ||
bspc query -T -n | jq -r '"split_dir=" + (.rectangle | if .width > .height then "east" else "south" end)' | ||
fi |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,30 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# focus - focus windows by class, instance name or title (bspwm only) | ||
|
||
class= | ||
instance= | ||
name= | ||
|
||
while (( $# )); do | ||
case $1 in | ||
-c|--class) | ||
shift | ||
class=$1 | ||
;; | ||
-i|--instance) | ||
shift | ||
instance=$1 | ||
;; | ||
-n|--name) | ||
shift | ||
name=$1 | ||
;; | ||
*) | ||
class=$1 | ||
;; | ||
esac | ||
shift | ||
done | ||
shopt -s lastpipe | ||
|
||
wm_data=$(bspc wm -d) | ||
|
||
history=() | ||
seen=() | ||
|
||
nodes=() | ||
jq <<< "$wm_data" -r --arg class "$class" --arg instance "$instance" ' | ||
.monitors[].desktops[].root//empty | | ||
recurse(.firstChild//empty, .secondChild//empty) | | ||
select(.client != null) | | ||
select($class == "" or (.client.className | test($class; "i"))) | | ||
select($instance == "" or (.client.instanceName | test($instance; "i"))) | | ||
.id | ||
' | | ||
while read -r node; do | ||
if [[ ! -v 'seen[$node]' ]]; then | ||
history+=("$node") | ||
seen[$node]=1 | ||
fi | ||
done < <(jq <<< "$wm_data" '.focusHistory | reverse | .[].nodeId | select(. > 0)') | ||
[[ ! $title || $(xtitle "$node") =~ $title ]] && nodes+=("$node") | ||
done | ||
|
||
if [[ $class || $instance ]]; then | ||
declare -A className=() instanceName=() | ||
jq_cb() { | ||
className[$1]=$2 | ||
instanceName[$1]=$3 | ||
} | ||
. <(jq <<< "$wm_data" -r '.monitors[].desktops[].root//empty | recurse(.firstChild//empty, .secondChild//empty) | | ||
["jq_cb", .id, (.client | .className//"", .instanceName//"")] | @sh') | ||
fi | ||
(( ${#nodes[@]} )) || exit | ||
|
||
for (( i = ${#history[@]} - 1; i >= 0; i-- )) do | ||
node=${history[i]} | ||
if [[ $class ]]; then | ||
[[ ${className[$node],,} == ${class,,} ]] || continue | ||
fi | ||
if [[ $instance ]]; then | ||
[[ ${instanceName[$node],,} == ${instance,,} ]] || continue | ||
fi | ||
if [[ $name ]]; then | ||
title=$(xtitle "$node") | ||
[[ ${title,,} == ${name,,} ]] || continue | ||
fi | ||
exec bspc node "$node" -f | ||
done | ||
jq <<< "$wm_data" -r ' | ||
.focusHistory | | ||
reduce to_entries[] as {$key, value: {$nodeId}} ( | ||
$ARGS.positional | map({key: ., value: -1}) | from_entries; | ||
(.[$nodeId | tostring]//empty) = $key | ||
) | to_entries | min_by(.value).key | ||
' --args "${nodes[@]}" | | ||
read -r node | ||
|
||
exit 1 | ||
bspc node "$node" -f |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,47 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# le - focus/launch stuff | ||
|
||
terminal() { | ||
local instance title focus_title columns lines hold | ||
[[ $instance ]] && class=alacritty instance="$instance" focus && return | ||
[[ $focus_title ]] && class=alacritty title="$focus_title" focus && return | ||
alacritty \ | ||
${instance:+--class "$instance"} \ | ||
${title:+--title "$title"} \ | ||
${columns:+-o window.dimensions.columns="$columns"} \ | ||
${lines:+-o window.dimensions.lines="$lines"} \ | ||
${hold:+--hold} \ | ||
${*:+-e "$@"} | ||
} | ||
|
||
# If -n is given, always create a new instance | ||
if [[ $1 == -n ]]; then | ||
focus() { | ||
return 1 | ||
} | ||
focus() { return 1; } | ||
shift | ||
fi | ||
|
||
case $1 in | ||
'') | ||
printf '%s\n' term irc text wifi info web mail files music video volume jap cal | ||
;; | ||
term|terminal) | ||
alacritty & | ||
;; | ||
terminal &;; | ||
irc) | ||
focus alacritty -i irc || { alacritty --class irc -e autossh -M 0 -- -qt monade.li tmux -L weechat attach & } | ||
;; | ||
instance=irc terminal autossh -M 0 -- -qt monade.li tmux -L weechat attach &;; | ||
text|editor) | ||
focus alacritty -n '* - vim' || { alacritty --class editor -e vim & } | ||
;; | ||
focus_title='- VIM$' terminal vim &;; | ||
wifi) | ||
focus alacritty -i wifi || { alacritty --class wifi --title wifi -o window.dimensions.columns=50 window.dimensions.lines=25 -e sudo wifi-menu & } | ||
;; | ||
instance=wifi title=wifi columns=50 lines=25 terminal sudo wifi-menu &;; | ||
info|details) | ||
BASH_STARTUP='details' alacritty --class info -o window.dimensions.columns=23 window.dimensions.lines=12 & | ||
;; | ||
instance=info columns=23 lines=12 BASH_STARTUP=details terminal &;; | ||
web|browser) | ||
focus firefox || { firefox & } | ||
;; | ||
class=firefox focus || { firefox & };; | ||
mail) | ||
#xdg-open 'https://mail.google.com/' & | ||
focus thunderbird || { thunderbird & } | ||
;; | ||
class=thunderbird focus || { thunderbird & };; | ||
files) | ||
focus thunar || { thunar & } | ||
;; | ||
class=thunar focus || { thunar & };; | ||
video) | ||
focus mpv | ||
;; | ||
class=mpv focus;; | ||
volume) | ||
focus pavucontrol || { pavucontrol & } | ||
;; | ||
class=pavucontrol focus || { pavucontrol & };; | ||
jap|japanese) | ||
pkill -x fcitx || { fcitx & } | ||
;; | ||
pkill -x fcitx || { fcitx & };; | ||
cal|calendar) | ||
alacritty --class calendar -o window.dimensions.columns=64 window.dimensions.lines=9 cursor.style=underline --hold -e cal -3 | ||
;; | ||
instance=calendar title=calendar columns=64 lines=9 hold=1 terminal cal -3 &;; | ||
esac |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
wallpaper=$(shuf -n 1 -e ~/pictures/horizontal/* ~/pictures/tileable/*) | ||
pictures=$(xdg-user-dir PICTURES) | ||
wallpaper=$(find "$pictures/horizontal" "$pictures/tileable" -type f | shuf -n 1) | ||
|
||
case $wallpaper in | ||
~/pictures/horizontal/*) | ||
feh --bg-fill "$wallpaper";; | ||
~/pictures/tileable/*) | ||
feh --bg-tile "$wallpaper";; | ||
$pictures/horizontal/*) | ||
mode=fill;; | ||
$pictures/tileable/*) | ||
mode=tile;; | ||
esac | ||
|
||
feh --bg-"$mode" "$wallpaper" |