34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
file="/tmp/.minimized"
|
|
touch "$file"
|
|
lines=$(awk 'END{print NR}' "$file")
|
|
icon="$HOME/img/.icn/Deskbar_Window_Visible.svg"
|
|
|
|
case $1 in
|
|
hide)
|
|
if [ "$lines" -ge 15 ]; then
|
|
notify-send -i "$icon" "15 ventanas minimizadas" "Mejor cerrar algunas antes de esconder todavía más"
|
|
else
|
|
focusedNode=$(bspc query -N -n .focused)
|
|
focusedID=$(bspc query -D -d --names)
|
|
focusedName=$(xprop -id "$focusedNode" WM_NAME | cut -d\" -f2)
|
|
|
|
echo "$focusedNode $focusedID $focusedName" >> "$file"
|
|
xdo hide "$focusedNode"
|
|
notiflines="$((lines + 1))"
|
|
[ "$notiflines" -gt 1 ] && notiftext="ventanas escondidas" || notiftext="ventana escondida"
|
|
notify-send -i "$icon" "${notiflines} $notiftext." "$focusedName"
|
|
fi
|
|
;;
|
|
show)
|
|
[ -z "$file" ] && exit
|
|
[ "$lines" -eq 1 ] && sel=$(awk '{print $2,$3}' "$file") || sel=$(awk '{print $2,$3}' "$file" | rofi -dmenu -p 'Ventanas Minimizadas')
|
|
selectedID=$(awk -v pat="$sel" '$0~pat {print $1}' "$file")
|
|
selectedDesktop=$(awk -v pat="$sel" '$0~pat {print $2}' "$file")
|
|
bspc desktop -f "$selectedDesktop"
|
|
xdo show "$selectedID"
|
|
sed -i "/${sel}/d" "$file"
|
|
;;
|
|
esac
|