mirror of
https://github.com/VectorKappa/dotfiles.git
synced 2025-12-19 08:16:10 +01:00
added binfiles from chrysostomus/bspwm-scripts, fixed eaten space
This commit is contained in:
10
bin/DidIClickDesktop.sh
Executable file
10
bin/DidIClickDesktop.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
# Did I just click the desktop?
|
||||
|
||||
#Get the window id of the window that is under the pointer and set variable WINDOW to it
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
|
||||
#Get the window id of the rootwindow aka desktop and convert the id into decimal form that xdotool uses so we can easily compare the values
|
||||
rootwindowid=$(xdotool search --class Bspwm|head -n 1)
|
||||
#Compare window ids to see if window under mouse is the rootwindow. Returns false if not.
|
||||
[ "$WINDOW" = "$rootwindowid" ]
|
||||
11
bin/MouseCenter
Executable file
11
bin/MouseCenter
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Get the necessary info
|
||||
#Script copied from https://github.com/tatou-tatou
|
||||
IFS=" " read -a window <<< $(wattr whxy $(pfw))
|
||||
|
||||
# Find the center of the window
|
||||
center_x=$(( ${window[0]} / 2 + ${window[2]} ))
|
||||
center_y=$(( ${window[1]} / 2 + ${window[3]} ))
|
||||
|
||||
# Move mouse
|
||||
xdotool mousemove $center_x $center_y
|
||||
16
bin/WindowSelector
Executable file
16
bin/WindowSelector
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Script copied from AUR package dswitcher, and modified for theming and placement and removed unnecessary functions.
|
||||
if ! [ -f "$HOME/.dmenurc" ]; then
|
||||
cp /usr/share/dmenu/dmenurc $HOME/.dmenurc
|
||||
fi
|
||||
. $HOME/.dmenurc
|
||||
|
||||
width=$(wattr w $(lsw -r))
|
||||
height=$(wattr h $(lsw -r))
|
||||
bar_width=$(( $width / 3 ))
|
||||
left_shift=$(( ($width - $bar_width) / 2 ))
|
||||
top_shift=$PANEL_HEIGHT
|
||||
|
||||
num=$(wmctrl -l | sed 's/ / /' | cut -d " " -f 4- | nl -w 3 -n rn | sed -r 's/^([ 0-9]+)[ \t]*(.*)$/\1 - \2/' | dmenu -i -l 10 -x $left_shift -y $top_shift -w $bar_width -fn $DMENU_FN -nb $DMENU_NB -nf $DMENU_NF -sf $DMENU_SF -sb $DMENU_SB | cut -d '-' -f -1)
|
||||
[[ -z "$num" ]] && exit
|
||||
wmctrl -l | sed -n "$num p" | cut -c -10 | xargs wmctrl -i -a
|
||||
13
bin/auto-presel
Executable file
13
bin/auto-presel
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /bin/sh
|
||||
# Original script by https://github.com/ikn/ , modified to use splitting method of
|
||||
# https://github.com/baskerville/bspwm/tree/master/examples/external_rules/pseudo_automatic_mode
|
||||
fwid=$(bspc query -N -n focused)
|
||||
|
||||
wattr wh $fwid | {
|
||||
read width height
|
||||
if [ $width -gt $height ] ; then
|
||||
bspc node -p \~east
|
||||
else
|
||||
bspc node -p \~south
|
||||
fi
|
||||
}
|
||||
21
bin/autogap
Executable file
21
bin/autogap
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if [ "$(pgrep -cx autogap)" -gt 1 ] ; then
|
||||
killall autogap && exit 0
|
||||
else
|
||||
|
||||
bspc config top_padding 0
|
||||
bspc config left_padding 0
|
||||
bspc config right_padding 0
|
||||
bspc config bottom_padding 0
|
||||
bspc config -m $(bspc query -M | awk NR==1) top_padding $PANEL_HEIGHT
|
||||
bspc config gapless_monocle true
|
||||
|
||||
bspc subscribe | while read line; do
|
||||
W=$(bspc query -N -n .local.\!floating | wc -l)
|
||||
G=$(echo "51 - ($W - 1) * 10" | bc)
|
||||
[ "$G" -lt 1 ] && G=1
|
||||
bspc config --desktop focused window_gap $G
|
||||
done
|
||||
|
||||
fi
|
||||
60
bin/bspcp
Executable file
60
bin/bspcp
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
i=1
|
||||
case $1 in
|
||||
dsktp) # Add or remove a desktop
|
||||
case $2 in
|
||||
add)
|
||||
current=$(bspc query -D | wc -l)
|
||||
if [ "$current" -lt "10" ]; then
|
||||
new=$((current + 1))
|
||||
bspc monitor -a $new
|
||||
else
|
||||
notify-send "You already have ten desktops" "Are those really necessary? Consider closing unneeded windows." -i warning
|
||||
fi
|
||||
;;
|
||||
rm)
|
||||
current=$(bspc query -D | wc -l)
|
||||
if [ "$current" -gt "4" ]; then
|
||||
bspc monitor -r $(bspc query -D | sed -n ${current}p)
|
||||
else
|
||||
notify-send "You currently have four desktops" "That can be considered a bare minimum. You should not remove more." -i warning
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
empty)
|
||||
nextFreeDesktop=$(bspc query -D -d next.free)
|
||||
|
||||
if [ -z "$nextFreeDesktop" ]
|
||||
then
|
||||
nextFreeDesktop=$(( $(bspc query -D | wc -l) + 1 ))
|
||||
bspc monitor -a $nextFreeDesktop
|
||||
fi
|
||||
|
||||
case $2 in
|
||||
move)
|
||||
bspc window -d $nextFreeDesktop
|
||||
;;
|
||||
next)
|
||||
bspc rule -a \* -o desktop=$nextFreeDesktop follow=true
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
tile) # Force every existing window to tile (the opposite is dumb IMHO)
|
||||
for window in $(bspc query -N -d focused)
|
||||
do
|
||||
bspc node $window -t tiled
|
||||
done
|
||||
;;
|
||||
float) # Force every existing window to float and place the windows
|
||||
for window in $(bspc query -N -d focused)
|
||||
do
|
||||
bspc node $window -t floating
|
||||
let i++
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
13
bin/bspwm_rename_desktop
Executable file
13
bin/bspwm_rename_desktop
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DMENU_NF="#A3A6AB"
|
||||
DMENU_NB="#34322E"
|
||||
DMENU_SF="#F6F9FF"
|
||||
DMENU_SB="#5C5955"
|
||||
|
||||
DESKTOP_NAME=`echo '' | dmenu -b $DMENU_THEME -p 'Rename:'`
|
||||
if [ -z $DESKTOP_NAME ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bspc desktop -n "$DESKTOP_NAME"
|
||||
41
bin/bspwm_resize.sh
Executable file
41
bin/bspwm_resize.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
size=${2:-'10'}
|
||||
dir=$1
|
||||
|
||||
# Find current window mode
|
||||
is_tiled() {
|
||||
bspc query -T -n | grep -q '"state":"tiled"'
|
||||
}
|
||||
# If the window is floating, move it
|
||||
if ! is_tiled; then
|
||||
#only parse input if window is floating,tiled windows accept input as is
|
||||
case "$dir" in
|
||||
west) switch="-w"
|
||||
sign="-"
|
||||
;;
|
||||
east) switch="-w"
|
||||
sign="+"
|
||||
;;
|
||||
north) switch="-h"
|
||||
sign="-"
|
||||
;;
|
||||
south) switch="-h"
|
||||
sign="+"
|
||||
;;
|
||||
esac
|
||||
xdo resize ${switch} ${sign}${size}
|
||||
|
||||
# Otherwise, window is tiled: switch with window in given direction
|
||||
else
|
||||
case "$dir" in
|
||||
west) bspc node @west -r -$size || bspc node @east -r -${size}
|
||||
;;
|
||||
east) bspc node @west -r +$size || bspc node @east -r +${size}
|
||||
;;
|
||||
north) bspc node @south -r -$size || bspc node @north -r -${size}
|
||||
;;
|
||||
south) bspc node @south -r +$size || bspc node @north -r +${size}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
2
bin/cancel_presels
Executable file
2
bin/cancel_presels
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
for window in $(bspc query -N -d focused); do bspc node $window -p cancel; done
|
||||
7
bin/clickpasser
Executable file
7
bin/clickpasser
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
#Script to allow clicking desktop in bspwm even if focus_follows_pointer is enabled
|
||||
pkill -USR2 -x sxhkd; \
|
||||
bspc config focus_follows_pointer off; \
|
||||
xdotool click $@; \
|
||||
bspc config focus_follows_pointer on; \
|
||||
pkill -USR2 -x sxhkd
|
||||
3
bin/default-browser
Executable file
3
bin/default-browser
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
. $HOME/.profile
|
||||
$BROWSER $@
|
||||
3
bin/default-editor
Executable file
3
bin/default-editor
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
. $HOME/.profile
|
||||
$GUI_EDITOR $@
|
||||
3
bin/default-terminal
Executable file
3
bin/default-terminal
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
. $HOME/.profile
|
||||
$TERMINAL $@
|
||||
13
bin/edge-switcher
Executable file
13
bin/edge-switcher
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
function on_exit {
|
||||
for child in $(jobs -p); do
|
||||
jobs -p | grep -q $child && kill $child
|
||||
done
|
||||
# Extra paranoia
|
||||
[[ -d "${state_path}" && -w "${state_path}" ]] && rm -rf -- "${state_path}"
|
||||
}
|
||||
|
||||
trap on_exit EXIT SIGHUP SIGINT SIGTERM
|
||||
|
||||
xdotool behave_screen_edge left exec bspc desktop -f prev &
|
||||
xdotool behave_screen_edge right exec bspc desktop -f next &
|
||||
14
bin/euclid_balancer
Executable file
14
bin/euclid_balancer
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if [ "$(pgrep -cx euclid_balancer)" -gt 1 ] ; then
|
||||
killall euclid_balancer && exit 0
|
||||
else
|
||||
|
||||
bspc subscribe node_add node_remove node_state node_geometry | while read line; do
|
||||
for wid in $(bspc query -N -d -n .window); do
|
||||
bspc node "${wid}#@north" -B || true
|
||||
bspc node "${wid}#@south" -B || true
|
||||
done
|
||||
done
|
||||
|
||||
fi
|
||||
15
bin/euclid_mode
Executable file
15
bin/euclid_mode
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /bin/sh
|
||||
|
||||
fwid=$(bspc query -N -n focused.automatic)
|
||||
wid=$1
|
||||
class=$2
|
||||
instance=$3
|
||||
title=$(xtitle "$wid")
|
||||
#floats=$(bspc query -N -n .local.floating | wc -l)
|
||||
if bspc query -N -n "@/.!automatic" > /dev/null ; then
|
||||
echo "node=@/"
|
||||
fi
|
||||
if [ -n "$fwid" ] ; then
|
||||
echo "split_dir=south"
|
||||
fi
|
||||
#window-placer $floats $wid
|
||||
85
bin/euclid_mover
Executable file
85
bin/euclid_mover
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# Originally by https://github.com/windelicato/
|
||||
|
||||
size=${2:-'20'}
|
||||
dir=$1
|
||||
|
||||
transplanter() {
|
||||
bspc node ${dir} -p south && bspc node -n ${dir}
|
||||
}
|
||||
|
||||
northplanter() {
|
||||
bspc node north -p north && bspc node -n north
|
||||
}
|
||||
|
||||
rootplanter() {
|
||||
bspc node @/ -p ${dir} && bspc node -n @/ || bspc node -s next.local && bspc node -n @/
|
||||
bspc node @/ -p cancel
|
||||
}
|
||||
|
||||
bspc config pointer_follows_focus true
|
||||
# Find current window mode
|
||||
is_floating() {
|
||||
bspc query -T -n | grep -q '"state":"floating"'
|
||||
}
|
||||
# If the window is floating, move it
|
||||
if is_floating; then
|
||||
#only parse input if window is floating,tiled windows accept input as is
|
||||
case "$dir" in
|
||||
west) switch="-x"
|
||||
sign="-"
|
||||
;;
|
||||
east) switch="-x"
|
||||
sign="+"
|
||||
;;
|
||||
north) switch="-y"
|
||||
sign="-"
|
||||
;;
|
||||
*) switch="-y"
|
||||
sign="+"
|
||||
;;
|
||||
esac
|
||||
xdo move ${switch} ${sign}${size}
|
||||
|
||||
# Otherwise, window is tiled: switch with window in given direction
|
||||
else
|
||||
if [[ $(bspc query -N -n .local.\!floating | wc -l) != 2 ]]; then
|
||||
case "$dir" in
|
||||
north) northplanter || rootplanter
|
||||
;;
|
||||
*) transplanter || rootplanter
|
||||
;;
|
||||
esac
|
||||
else
|
||||
case "$dir" in
|
||||
east) bspc node -s east || bspc query -N -n west.local || \
|
||||
if bspc query -N -n south.local ; then
|
||||
bspc node @/ -R 90
|
||||
else
|
||||
bspc node @/ -R 270
|
||||
fi
|
||||
;;
|
||||
west) bspc node -s west || bspc query -N -n east.local || \
|
||||
if bspc query -N -n north.local ; then
|
||||
bspc node @/ -R 90
|
||||
else
|
||||
bspc node @/ -R 270
|
||||
fi
|
||||
;;
|
||||
south) bspc node -s south || bspc query -N -n north.local || \
|
||||
if bspc query -N -n west.local ; then
|
||||
bspc node @/ -R 90
|
||||
else
|
||||
bspc node @/ -R 270
|
||||
fi
|
||||
;;
|
||||
*) bspc node -s north || bspc query -N -n south.local || \
|
||||
if bspc query -N -n west.local ; then
|
||||
bspc node @/ -R 270
|
||||
else
|
||||
bspc node @/ -R 90
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
24
bin/finder
Executable file
24
bin/finder
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# A fuzzy file-finder and opener based on dmenu
|
||||
# Requires: dmenu, xdg-utils
|
||||
if ! [ -f "$HOME/.dmenurc" ]; then
|
||||
cp /usr/share/dmenu/dmenurc $HOME/.dmenurc
|
||||
fi
|
||||
. $HOME/.dmenurc
|
||||
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
menu_widht=600
|
||||
monitor_widht=$(wattr w $(lsw -r))
|
||||
monitor_height=$(wattr h $(lsw -r))
|
||||
lines=20
|
||||
menu_height=$(( $lines * 23 ))
|
||||
maxx=$(( $monitor_widht - $menu_widht ))
|
||||
miny=$PANEL_HEIGHT
|
||||
maxy=$(( $monitor_height - $menu_height ))
|
||||
XP=$X
|
||||
[[ $XP -gt $maxx ]] && XP=$maxx
|
||||
YP=$Y
|
||||
[[ $YP -lt $miny ]] && YP=$miny
|
||||
[[ $YP -gt $maxy ]] && YP=$maxy
|
||||
|
||||
find ~/ | sed 's/ /\\ /g' | sort -f | dmenu -i -l $lines -y $YP -x $XP -w $menu_widht -fn $DMENU_FN -nb $DMENU_NB -nf $DMENU_NF -sf $DMENU_SF -sb $DMENU_SB | xargs xdg-open
|
||||
7
bin/focusdesktopofthismonitor
Executable file
7
bin/focusdesktopofthismonitor
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
#Focus nth desktop of focused monitor for i3 style keybinds
|
||||
#
|
||||
#super + {1-9}
|
||||
# focusdesktopofthismonitor ^{1-9}
|
||||
D=$@; \
|
||||
bspc desktop -f "$(bspc query -D -m | sed -n "$D p")"
|
||||
13
bin/focusmover
Executable file
13
bin/focusmover
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#Focus windows by direction, works with multihead
|
||||
#called like this in sxhkdrc:
|
||||
#super + {a,s,w,d}
|
||||
# focusmover {west,south,north,east}
|
||||
bspc config pointer_follows_monitor true; \
|
||||
bspc config pointer_follows_focus true; \
|
||||
dir=$@; \
|
||||
if ! bspc node -f $dir; then \
|
||||
bspc monitor -f $dir; \
|
||||
fi; \
|
||||
bspc config pointer_follows_monitor false; \
|
||||
bspc config pointer_follows_focus false
|
||||
13
bin/get-window-alignment
Executable file
13
bin/get-window-alignment
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /bin/sh
|
||||
# By https://github.com/tatou-tatou
|
||||
id="$(bspc query -N -n "${1:-focused}" | head -n1)"
|
||||
[ -z "$id" ] && exit 1
|
||||
|
||||
w=$(wattr w "$id")
|
||||
h=$($(wattr h "$id")
|
||||
|
||||
if [ "$w" -gt "$h" ]; then
|
||||
echo horizontal
|
||||
else
|
||||
echo vertical
|
||||
fi
|
||||
66
bin/keybindings.sh
Executable file
66
bin/keybindings.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
less <<-EOF
|
||||
List of some useful keybindings.
|
||||
More can be found from the file ~/.config/sxhkd/sxhkdrc.
|
||||
You can also edit keybindings there.
|
||||
|
||||
Mod4 is super key, on many keyboards marked with windows logo.
|
||||
As a rule of thumb, super+<direction> moves focus,
|
||||
super+shift+<direction> moves focused window,
|
||||
and super+ctrl+<direction> resizes windows.
|
||||
|
||||
Arrow keys, wasd and hjkl represent directions and numbers represent
|
||||
different workspaces.
|
||||
|
||||
### Window manipulation ################################################################
|
||||
|
||||
Alt + Tab |- Cycle windows
|
||||
Super + Tab |- Open window switcher
|
||||
Super + x |- Close window
|
||||
Super + shift + x |- Kill window
|
||||
Super + <direction> |- Move focus to the direction
|
||||
Super + shift + <direction> |- Move focused window to direction
|
||||
Super + ctrl + <direction> |- Resize focused window to direction
|
||||
Alt + shift + <direction> |- Preselect/split the rootwindow
|
||||
Super + 1-9 |- Focus the desktop with that number
|
||||
Super + shift + 1-9 |- Move focused window to desktop with that number
|
||||
Super + Enter |- Move window to the biggest available space
|
||||
| or preselection if there is one
|
||||
Super + ctrl + Enter |- Preselect where the next window will be opened
|
||||
Ctrl + space |- Preselect where the next window will be opened
|
||||
Alt + Enter |- Preselect/split the rootwindow
|
||||
Super + b |- Balance windows
|
||||
Alt + b |- Toggle automatic window balancing
|
||||
Super + i |- Make window sticky
|
||||
Super + t |- Toggle tiling/floating
|
||||
Super + shift + t |- Toggle pseudotiling
|
||||
Super + shift + f |- Toggle fullscreen
|
||||
Super + f |- Toggle monocle
|
||||
Super + o |- Make window private
|
||||
| (Avoids splitting it automatically)
|
||||
Super + shift + q |- Cleanly quit bspwm
|
||||
Super + shift + r |- Reload bspwms configuration file
|
||||
### Mousecommands ######################################################################
|
||||
|
||||
Leftclick menus |- Close menu
|
||||
Super + scroll |- Adjust window gap
|
||||
Super + drag |- Moves window
|
||||
Super + rightclick drag |- Resizes window
|
||||
Alt + leftclick |- Spawn window manipulation menu on cursor
|
||||
Alt_gr + leftclick |- Split window depending on mouselocation
|
||||
| and spawn application menu
|
||||
### Applications #######################################################################
|
||||
|
||||
Super + p |- Dmenu (Run applications)
|
||||
Super + space |- Dmenu (Run applications)
|
||||
Super + shift + b |- Browser
|
||||
Super + r |- File search
|
||||
Super + e |- Explore files with SpaceFM
|
||||
Super + shift + e |- Explore files with Ranger
|
||||
Super + shift + Return |- Terminal
|
||||
Super + z |- Terminal
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
56
bin/list_windows_by_size.sh
Executable file
56
bin/list_windows_by_size.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
#client != null => container mit window
|
||||
#rectangle => container size
|
||||
#client.window => window id
|
||||
# USAGE=\
|
||||
# "$(basename $0) [option]
|
||||
# options:
|
||||
# num any real number 1 -> biggest window 2 -> second biggest ...
|
||||
# nothing print all windwos on desktop sorted by size biggest first\
|
||||
# "
|
||||
tree=$(bspc wm -d| jshon -e root -j)
|
||||
|
||||
function print_childs {
|
||||
tree=$1
|
||||
fChild=$(echo $tree| jshon -e firstChild -j)
|
||||
sChild=$(echo $tree| jshon -e secondChild -j)
|
||||
for Child in $fChild $sChild; do
|
||||
if [ "$(echo $Child| jshon -e client)" != "null" ]; then
|
||||
window=$(echo $Child| jshon -e client -e window)
|
||||
#echo $Child| jshon -e rectangle
|
||||
height=$(echo $Child| jshon -e rectangle -e height)
|
||||
width=$(echo $Child| jshon -e rectangle -e width)
|
||||
echo "$window:$(( height * width ))"
|
||||
else
|
||||
print_childs $Child
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#store window ids in array sorted by size
|
||||
windows=( $(print_childs $tree| sort -t":" -rnk2| cut -d":" -f1 ) )
|
||||
windows_len=$(( ${#windows[@]} -1 ))
|
||||
|
||||
#getOpts
|
||||
#no options => print all ids sorted by leave size (window tiled + border)
|
||||
if [ $# -ne 1 ]; then
|
||||
for id in ${windows[@]}; do
|
||||
echo $id
|
||||
done
|
||||
|
||||
# check if $1 is a number
|
||||
elif ! [ "$1" -eq "$1" ] 2> /dev/null; then
|
||||
echo "$USAGE"
|
||||
|
||||
# print the x. biggest window 1 biggest 2 second biggest ...
|
||||
# number higher then windows => print last (tinyst window)
|
||||
else
|
||||
[ $1 -gt 0 ] && index=$(( $1 -1 ))
|
||||
|
||||
if [ $index -gt $windows_len ]; then
|
||||
index=$windows_len
|
||||
fi
|
||||
|
||||
echo ${windows[$index]}
|
||||
fi
|
||||
5
bin/movetodesktopofthismonitor
Executable file
5
bin/movetodesktopofthismonitor
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
#super + shift + {1-9}
|
||||
# movetodesktopofthismonitor ^{1-9}
|
||||
D=$@; \
|
||||
bspc node -d "$(bspc query -D -m | sed -n "$D p")"
|
||||
29
bin/pseudo_automatic_mode
Executable file
29
bin/pseudo_automatic_mode
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /bin/sh
|
||||
|
||||
fwid=$(bspc query -N -n focused.automatic)
|
||||
wid=$1
|
||||
class=$2
|
||||
instance=$3
|
||||
title=$(xtitle "$wid")
|
||||
receptacle=$(bspc query -N -n ".leaf.!window.local" | awk NR==1)
|
||||
#floats=$(bspc query -N -n .local.floating | wc -l)
|
||||
|
||||
if bspc query -N -n "@/.!automatic" > /dev/null ; then
|
||||
echo "node=@/"
|
||||
fi
|
||||
|
||||
if [ -n "$receptacle" ] > /dev/null ; then
|
||||
echo "node=$receptacle"
|
||||
elif [ -n "$fwid" ] ; then
|
||||
wattr wh $fwid | {
|
||||
read width height
|
||||
if [ $width -gt $height ] ; then
|
||||
echo "split_dir=west"
|
||||
else
|
||||
echo "split_dir=south"
|
||||
fi
|
||||
# echo "split_ratio=0.5"
|
||||
}
|
||||
fi
|
||||
wmctrl -i -r "$wid" -b add,maximized_vert,maximized_horz &>/dev/null &
|
||||
#window-placer $floats $wid
|
||||
83
bin/resizetopresel.sh
Executable file
83
bin/resizetopresel.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Check if the brother node is a receptacle
|
||||
if [[ $(bspc query -T -n @brother/ | jshon -e client) = null ]]; then
|
||||
# Yep, it's a receptacle. Get the real dimensions
|
||||
eval $(grep "gap=" .config/bspwm/bspwmrc)
|
||||
# Get orientation
|
||||
wattr xywh $(pfw) | read focused_x focused_y focused_width focused_height
|
||||
receptacle_y=$(bspc query -T -n @brother/ | jshon -e rectangle -e y)
|
||||
|
||||
if [[ "$focused_y" -eq "$receptacle_y" ]]; then
|
||||
receptacle_width=$(bspc query -T -n @brother/ | jshon -e rectangle -e width)
|
||||
receptacle_x=$(bspc query -T -n @brother/ | jshon -e rectangle -e x)
|
||||
# receptacle and window have the same height, so they are side by side
|
||||
if [[ receptacle_x -gt focused_x ]]; then
|
||||
echo "receptacle is right of the window"
|
||||
# get the true window dimension
|
||||
true_dim=$(( receptacle_width + gap ))
|
||||
# kill the repectacle
|
||||
for i in $(bspc query -N -n .leaf.!window.local); do bspc node $i -k; done
|
||||
# resize the window
|
||||
bspc node @east -r -$true_dim || bspc node @west -r +$true_dim
|
||||
else
|
||||
echo "receptacle is left of the window"
|
||||
# get the true window dimension
|
||||
true_dim=$(( receptacle_width + gap ))
|
||||
# kill the repectacle
|
||||
for i in $(bspc query -N -n .leaf.!window.local); do bspc node $i -k; done
|
||||
# resize the window
|
||||
bspc node @west -r +$true_dim || bspc node @east -r -$true_dim
|
||||
fi
|
||||
else
|
||||
receptacle_height=$(bspc query -T -n @brother/ | jshon -e rectangle -e height)
|
||||
# widht is necessarily equal if height is not, because the nodes are brothers
|
||||
# Window are on the top of each other
|
||||
if [[ receptacle_y -gt focused_y ]]; then
|
||||
echo "receptacle is below the window"
|
||||
# get the true window dimension
|
||||
true_dim=$(( receptacle_height + gap))
|
||||
# kill the repectacle
|
||||
for i in $(bspc query -N -n .leaf.!window.local); do bspc node $i -k; done
|
||||
# resize the window
|
||||
bspc node @south -r -$true_dim || bspc node @north -r +$true_dim
|
||||
else
|
||||
echo "receptacle is above the window"
|
||||
# get the true window dimension
|
||||
true_dim=$(( receptacle_height + gap))
|
||||
# kill the repectacle
|
||||
for i in $(bspc query -N -n .leaf.!window.local); do bspc node $i -k; done
|
||||
# resize the window
|
||||
bspc node @north -r +$true_dim || bspc node @south -r -$true_dim
|
||||
fi
|
||||
fi
|
||||
echo $true_dim
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If the focused window is not preselected, exit
|
||||
[[ "$(bspc query -T -n focused | jshon -e presel)" == null ]] && exit 0
|
||||
|
||||
dir=$(bspc query -T -n focused | jshon -e presel -e splitDir | tr -d \")
|
||||
ratio=$(bspc query -T -n focused | jshon -e presel -e splitRatio)
|
||||
|
||||
case "$dir" in
|
||||
west)
|
||||
cur=$(bspc query -T -n focused | jshon -e rectangle -e width)
|
||||
bspc node @west -r +$((${cur}*${ratio})) || bspc node @east -r -$((${cur}*${ratio}))
|
||||
;;
|
||||
east)
|
||||
cur=$(bspc query -T -n focused | jshon -e rectangle -e width)
|
||||
bspc node @east -r -$((${cur}*${ratio})) || bspc node @west -r +$((${cur}*${ratio}))
|
||||
;;
|
||||
|
||||
north)
|
||||
cur=$(bspc query -T -n focused | jshon -e rectangle -e height)
|
||||
bspc node @north -r +$((${cur}*${ratio})) || bspc node @south -r -$((${cur}*${ratio}))
|
||||
;;
|
||||
south)
|
||||
cur=$(bspc query -T -n focused | jshon -e rectangle -e height)
|
||||
bspc node @south -r -$((${cur}*${ratio})) || bspc node @north -r +$((${cur}*${ratio}))
|
||||
esac
|
||||
|
||||
cancel_presels
|
||||
3
bin/run_once
Executable file
3
bin/run_once
Executable file
@@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
# Run program unless it's already running
|
||||
pgrep $@ > /dev/null || ($@ &)
|
||||
31
bin/smartsplit
Executable file
31
bin/smartsplit
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Window splitting script for bspwm. Requires wmutils and xdotool. Splits window in its biggest dimension
|
||||
# in the direction that is closer to the cursor. Inspired by MouseLaunch and pseudo_automatic_rule.
|
||||
# Get the necessary info
|
||||
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))
|
||||
|
||||
# Distance to each side
|
||||
north=$(( $Y - ${window[3]}))
|
||||
south=$(( ${window[3]} + ${window[1]} - $Y ))
|
||||
west=$(( $X - ${window[2]}))
|
||||
east=$(( ${window[2]} + ${window[0]} - $X ))
|
||||
# Dimensions of window
|
||||
widht=${window[0]}
|
||||
height=${window[1]}
|
||||
|
||||
# Determine which window edge in biggest dimension is closer
|
||||
if [[ "$widht" -lt "$height" ]] && [[ "$north" -lt "$south" ]]; then
|
||||
dir_final=north
|
||||
elif [[ "$widht" -lt "$height" ]] && [[ "$north" -ge "$south" ]]; then
|
||||
dir_final=south
|
||||
elif [[ "$widht" -ge "$height" ]] && [[ "$east" -ge "$west" ]]; then
|
||||
dir_final=west
|
||||
else
|
||||
dir_final=east
|
||||
fi
|
||||
|
||||
# Split the window accordingly
|
||||
bspc node -p \~$dir_final
|
||||
#echo "north=$north east=$east south=$south west=$west widht=$widht Height=$height $dir_final"
|
||||
14
bin/summondesktop.sh
Executable file
14
bin/summondesktop.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /bin/sh
|
||||
#in sxhkdrc call it with
|
||||
#alt + {1-9,0}
|
||||
# summonworkspace.sh {1-9,0}
|
||||
D=$(bspc query -D -m | sed -n "$@ p"); \
|
||||
M=$(bspc query --monitors --desktop $D); \
|
||||
if [ $(bspc query --desktops --monitor $M | wc -l) -gt 1 ]; then \
|
||||
if [ $(bspc query --desktops --desktop focused) != $D ]; then \
|
||||
bspc desktop $D --to-monitor focused; \
|
||||
bspc desktop $D --focus; \
|
||||
fi; \
|
||||
elif [ $(bspc query --monitors --monitor focused) != $M ]; then \
|
||||
bspc desktop $(bspc query --monitors --desktop $D):focused --swap $(bspc query -M -m focused):focused; \
|
||||
fi
|
||||
4
bin/swapOrMoveIn.sh
Executable file
4
bin/swapOrMoveIn.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
#By https://github.com/ikn/
|
||||
dir=$1
|
||||
bspc node -n ${dir}.!automatic || bspc node -s ${dir}
|
||||
15
bin/toggle-focus-follows-pointer
Executable file
15
bin/toggle-focus-follows-pointer
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Purpose: toggle focus with mouse. This needs to be
|
||||
# disabled for wonky java stuff, see:
|
||||
# https://bbs.archlinux.org/viewtopic.php?pid=1448554#p1448554
|
||||
#
|
||||
# Thanks matchew, for your awesome script!
|
||||
# ------------------------------------------------------------
|
||||
|
||||
toggle=$(bspc config focus_follows_pointer | \
|
||||
awk -vtoggle="true" \
|
||||
'{ if ($1 == "true") toggle="false"; print toggle }')
|
||||
|
||||
bspc config focus_follows_pointer $toggle
|
||||
7
bin/toggle-pointer-follows-focus
Executable file
7
bin/toggle-pointer-follows-focus
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
toggle=$(bspc config pointer_follows_focus | \
|
||||
awk -vtoggle="true" \
|
||||
'{ if ($1 == "true") toggle="false"; print toggle }')
|
||||
|
||||
bspc config pointer_follows_focus $toggle
|
||||
78
bin/whid
Executable file
78
bin/whid
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
file="/tmp/.minimized"
|
||||
touch $file
|
||||
# By https://github.com/tatou-tatou
|
||||
width=$(wattr w $(lsw -r))
|
||||
height=$(wattr h $(lsw -r))
|
||||
bar_width=$(( $width / 2 ))
|
||||
left_shift=$(( ($width - $bar_width) / 2 ))
|
||||
top_shift=$(( $height / 3 ))
|
||||
|
||||
case $1 in
|
||||
hide)
|
||||
lines=$(wc -l < $file)
|
||||
|
||||
if [[ $lines -ge 10 ]]; then ## Fight against bad practices
|
||||
notify-send "Ten windows are already hidden" "You should consider closing some before hiding even more." -i warning
|
||||
else
|
||||
focusedID=$(xdo id)
|
||||
if [[ "$focusedID" ]]; then
|
||||
focusedName=$(xdotool getwindowname $focusedID)
|
||||
focusedDesktop=$(xdotool get_desktop)
|
||||
|
||||
echo "$focusedID $focusedDesktop $focusedName" >> $file && xdo hide $focusedID && notify-send "A window has been hidden (${lines})." "$focusedName" -i warning
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
dmenu)
|
||||
miniList=$(cat $file)
|
||||
|
||||
# Dmenu cannot draw more than 30 lines
|
||||
lines=$(wc -l < $file)
|
||||
if [[ $lines -gt 30 ]]
|
||||
then linesDisplayed=30
|
||||
else linesDisplayed=$lines
|
||||
fi
|
||||
|
||||
# If the list is empty
|
||||
if [ -z "$miniList" ]
|
||||
then
|
||||
miniList=" Nothing is hidden!"
|
||||
linesDisplayed=1
|
||||
fi
|
||||
|
||||
# Calculate where to draw the dmenu popup.
|
||||
# Comment that line if you use vanilla dmenu.
|
||||
yPos=$((410-$linesDisplayed*10))
|
||||
|
||||
|
||||
# Uncomment only one line with dmenu_cmd
|
||||
# If you use rofi
|
||||
dmenu_cmd="rofi -lines $linesDisplayed -dmenu -p Hidden:"
|
||||
|
||||
# If you use dmenu, patched with eye candy
|
||||
# dmenu_cmd="dmenu -l 9 -x $left_shift -y $top_shift -w $bar_width -fn sans-11 -nb #201F1D -nf #eddec9 -sb #8F3724 -sf #EDDEC9 -p Hidden:"
|
||||
|
||||
# If you use vanilla dmenu
|
||||
# dmenu_cmd="dmenu -b -i -l $linesDisplayed -p Hidden:"
|
||||
|
||||
# Launch dmenu
|
||||
lineNumber=$(echo "$miniList" | cut -d " " -f 3- | nl -w 3 -n rn | sed -r 's/^([ 0-9]+)[ \t]*(.*)$/\1 - \2/' | $dmenu_cmd | cut -d '-' -f -1)
|
||||
|
||||
# If you exited dmenu without selecting anything or if the list was empty
|
||||
[ -z "$lineNumber" -o "$miniList" = " Nothing is hidden!" ] && exit
|
||||
|
||||
# Show the selected hidden window
|
||||
selectedID=$(sed -n "$lineNumber p" $file | cut -d ' ' -f 1)
|
||||
selectedDesktop=$(sed -n "$lineNumber p" $file | cut -d ' ' -f 2)
|
||||
xdotool set_desktop $selectedDesktop
|
||||
xdo show $selectedID && sed -i "${lineNumber}d" $file
|
||||
;;
|
||||
last)
|
||||
lines=$(wc -l < $file)
|
||||
selectedID=$(tail -n 1 $file | cut -d ' ' -f 1)
|
||||
selectedDesktop=$(sed -n "$lines p" $file | cut -d ' ' -f 2)
|
||||
xdotool set_desktop $selectedDesktop
|
||||
xdo show $selectedID && sed -i "${lines}d" $file
|
||||
;;
|
||||
esac
|
||||
43
bin/windowgrabber
Executable file
43
bin/windowgrabber
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/zsh
|
||||
# Originally by https://github.com/windelicato/
|
||||
# edited beyound recognition
|
||||
|
||||
follower() {
|
||||
if [ "$(pgrep -cx windowgrabber)" = 1 ] ; then
|
||||
bspc config pointer_follows_focus false
|
||||
fi
|
||||
}
|
||||
|
||||
trap 'follower' INT TERM QUIT EXIT
|
||||
|
||||
size=${2:-'20'}
|
||||
dir=$1
|
||||
|
||||
bspc config pointer_follows_focus true
|
||||
# Find current window mode
|
||||
is_floating() {
|
||||
bspc query -T -n | grep -q '"state":"floating"'
|
||||
}
|
||||
# If the window is floating, move it
|
||||
if is_floating; then
|
||||
#only parse input if window is floating,tiled windows accept input as is
|
||||
case "$dir" in
|
||||
west) switch="-x"
|
||||
sign="-"
|
||||
;;
|
||||
east) switch="-x"
|
||||
sign="+"
|
||||
;;
|
||||
north) switch="-y"
|
||||
sign="-"
|
||||
;;
|
||||
*) switch="-y"
|
||||
sign="+"
|
||||
;;
|
||||
esac
|
||||
xdo move ${switch} ${sign}${size}
|
||||
|
||||
# Otherwise, window is tiled: switch with window in given direction
|
||||
else
|
||||
bspc node -n ${dir}.!automatic || bspc node -s ${dir} || bspc node -m ${dir} && bspc monitor -f
|
||||
fi
|
||||
26
bin/windowpromoter
Executable file
26
bin/windowpromoter
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/sh
|
||||
|
||||
receptacle=$(bspc query -N -n ".leaf.!window.local" | awk NR==1)
|
||||
|
||||
window_promotion()
|
||||
{
|
||||
if [ -n "$receptacle" ] > /dev/null ; then
|
||||
bspc node -n "$receptacle"
|
||||
elif [ -z "$(bspc query -N -n last.!automatic.local)" ]; then \
|
||||
bspc node -s biggest.!focused.local; \
|
||||
else \
|
||||
bspc node -n last.!automatic.local; \
|
||||
fi
|
||||
}
|
||||
|
||||
if bspc query -N -n "@/.!automatic" > /dev/null ; then
|
||||
bspc node -n @/ || window_promotion
|
||||
else
|
||||
if [ -n "$receptacle" ] > /dev/null ; then
|
||||
bspc node -n "$receptacle"
|
||||
elif [ -z "$(bspc query -N -n last.!automatic.local)" ]; then \
|
||||
bspc node -s biggest.!focused.local; \
|
||||
else \
|
||||
bspc node -n last.!automatic.local; \
|
||||
fi
|
||||
fi
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
all_monitors=$(xrandr -q | awk '/connected/ {print $1}')
|
||||
all_monitors=$(xrandr -q | awk '/ connected/ {print $1}')
|
||||
default_screen=$(xrandr | awk '/ connected/ {print $1;exit;}')
|
||||
extra_monitors=$(xrandr -q | awk '/ connected/ {print $1}' | grep -v $default_screen)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user