mabox-pipemenus/usr/bin/jgdesktops

138 lines
3.8 KiB
Plaintext
Raw Normal View History

2021-05-18 16:48:04 +02:00
#!/bin/bash
# jgdesktops
#
2021-05-22 02:00:30 +02:00
case $LANG in
pl*)
REMOVE="Usuń to menu z panelu"
2021-05-31 15:00:35 +02:00
ACTIVE="bieżący"
GOTO="Idź do..."
WINKILL="Zabijacz Okien"
CLOSEALL_GR="Z wdziękiem zamknij wszystkie okna na..."
CLOSEALL="Zamknij wszystkie okna na..."
DESKTOP="Pulpicie"
ALL_DESK="Wszystkich pulpitach"
MANAGE="Pulpity"
ADD="<b>Dodaj nowy</b>"
2021-08-12 22:05:22 +02:00
REMOVE_LAST="<b>Usuń ostatni</b>"
2021-05-31 15:00:35 +02:00
DESKMNGR="Menadżer sesji pulpitowych"
2021-05-22 02:00:30 +02:00
;;
es*)
REMOVE="Eliminar este menú del panel"
2021-05-31 15:00:35 +02:00
ACTIVE="active"
GOTO="Go to..."
WINKILL="Windows Killer"
CLOSEALL_GR="Gracefully close all windows on..."
CLOSEALL="Close all windows on..."
DESKTOP="Desktop"
ALL_DESK="All Desktops"
MANAGE="Manage Desktops"
ADD="<b>Add new</b> desktop"
2021-08-12 22:05:22 +02:00
REMOVE_LAST="<b>Remove last</b> desktop"
2021-05-31 15:00:35 +02:00
DESKMNGR="Desktop session Manager"
2021-05-22 02:00:30 +02:00
;;
*)
REMOVE="Remove this menu from panel"
2021-05-31 15:00:35 +02:00
ACTIVE="active"
GOTO="Go to..."
WINKILL="Windows Killer"
CLOSEALL_GR="Gracefully close all windows on..."
CLOSEALL="Close all windows on..."
DESKTOP="Desktop"
ALL_DESK="All Desktops"
MANAGE="Manage Desktops"
ADD="<b>Add new</b> desktop"
2021-08-12 22:05:22 +02:00
REMOVE_LAST="<b>Remove last</b> desktop"
2021-05-31 15:00:35 +02:00
DESKMNGR="Desktop session Manager"
;;
2021-05-22 02:00:30 +02:00
esac
2021-05-18 16:48:04 +02:00
currdesk=$(wmctrl -d | grep "*" | awk '{print $1}')
#out+=("^sep(Okna i pulpity)")
i=0
while IFS= read -r linia || [ -n "$linia" ];
do
name=""
read -r ID name< <(echo $linia)
#declare -g "arr$ID"=("$name, wmctrl -s $ID")
dname=$(wmctrl -d | grep ^${ID} | cut -d' ' -f13-)
if [[ "$ID" = "$currdesk" ]]; then
2021-05-31 15:00:35 +02:00
out+=("^sep(<i><small>${dname/&/&amp;} ($ACTIVE)</small></i>)")
2021-05-18 16:48:04 +02:00
else
2021-06-09 12:25:27 +02:00
out+=("^sep(<i><small>${dname/&/&amp;}</small></i>)" " <i>$GOTO</i>,wmctrl -s $ID")
2021-05-18 16:48:04 +02:00
fi
while IFS= read -r line
do
read -r id DESK host title< <(echo $line)
if [[ "$DESK" = "$ID" ]]; then
trimmed=${title:0:60}
out+=("\"\"\"[ ${trimmed/&/&amp;} ]\"\"\",wmctrl -i -a $id")
fi
done < <(wmctrl -l| grep -v " -1")
done < <(wmctrl -d|awk '{print $1" "$10" "$11}')
# Gracefully close windows on any desktop or all windows
if [ $(wmctrl -l | awk $2 '!/-1/ {print $2}' | uniq |wc -l) -gt 0 ];then
2021-05-31 15:00:35 +02:00
out+=("^sep($WINKILL)")
out+=("$CLOSEALL_GR,^checkout(killwin)")
out2+=("^tag(killwin)" "^sep($CLOSEALL)")
2021-05-18 16:48:04 +02:00
for i in $(wmctrl -l | awk $2 '!/-1/ {print $2}' |sort| uniq)
do
dname=$(wmctrl -d | grep ^${i} | cut -d' ' -f13-)
2021-06-09 12:25:27 +02:00
out2+=(" $DESKTOP ${dname/&/&amp;},killwindows $i")
2021-05-18 16:48:04 +02:00
done
2021-05-31 15:00:35 +02:00
out2+=("^sep()" "$ALL_DESK,killwindows all")
2021-05-18 16:48:04 +02:00
fi
2021-05-31 15:00:35 +02:00
out+=("^sep($MANAGE)")
2021-05-18 16:48:04 +02:00
desktops=$(wmctrl -d |wc -l)
2021-05-31 15:00:35 +02:00
out+=("  $ADD,wmctrl -n $((desktops+1))")
2021-08-12 22:05:22 +02:00
out+=("  $REMOVE_LAST,wmctrl -n $((desktops-1))")
2021-05-18 16:48:04 +02:00
out+=("^sep()")
2021-05-31 15:00:35 +02:00
out+=("$DESKMNGR,jgdeskmngr -s")
2021-05-18 16:48:04 +02:00
### RUN
2021-05-22 02:00:30 +02:00
if [[ $1 == "-s" ]]; then
2021-05-18 16:48:04 +02:00
. /usr/bin/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
if [[ $panels_heightpos == "top" ]]; then
MENU_VALIGN="top"
MENU_MARGIN_Y=${panels_topmargin:-0}
elif [[ $panels_heightpos == "bottom" ]]; then
MENU_VALIGN="bottom"
MENU_MARGIN_Y=${panels_topmargin:-0}
else
MENU_VALIGN="center"
fi
2021-05-31 15:00:35 +02:00
MENU_PADDING_TOP=${jgtools_padding:-0}
2021-05-18 16:48:04 +02:00
MENU_HALIGN="center"
2021-05-18 16:48:04 +02:00
jgmenu_icon_size=0
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
if [[ $1 == "-r" ]]; then
printf '%s\n' "^sep()"
2021-05-23 10:20:13 +02:00
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdesktops=false;mb-jgtools places"
2021-05-18 16:48:04 +02:00
fi
printf '%s\n' "${out2[@]}"