mabox-pipemenus/usr/bin/jgdeskmngr

78 lines
1.9 KiB
Plaintext
Raw Normal View History

2021-05-18 16:48:04 +02:00
#!/bin/bash
# jgdeskmngr - pipemenu for deskmngr
#
2021-05-22 02:00:30 +02:00
case $LANG in
pl*)
REMOVE="Usuń to menu z panelu"
;;
es*)
REMOVE="Eliminar este menú del panel"
;;
*)
REMOVE="Remove this menu from panel"
;;
esac
2021-05-18 16:48:04 +02:00
SESSIONDIR="$HOME/.config/deskmngr/"
mkdir -p $SESSIONDIR
out+=("^sep(Desktop session Manager)")
out+=("^sep(<i><small>Saved sessions </small></i>)")
i="0"
while IFS= read -r line
do
name=$(basename $line .desk)
2021-05-21 23:15:53 +02:00
out+=("  ${name//_/ },^checkout(sess${i})")
2021-05-18 16:48:04 +02:00
out2+=("^tag(sess${i})")
out2+=("^sep(Restore to desktop...)")
while IFS= read -r linia || [ -n "$linia" ];
do read -r ID dname< <(echo $linia)
dname=$(wmctrl -d | grep ^${ID} | cut -d' ' -f13-)
2021-05-21 23:15:53 +02:00
out2+=("\"\"\"  ${dname/&/&amp;}\"\"\",deskmngr -r $name.desk $ID")
2021-05-18 16:48:04 +02:00
done < <(wmctrl -d|awk '{print $1}')
out2+=("^sep()" "  <b>Edit</b> session: <b>${name//_/ }</b>,geany $SESSIONDIR$name.desk")
out2+=("^sep()" "  <b>Delete</b> session: <b>${name//_/ }</b>,rm -f $SESSIONDIR$name.desk")
((i=i+1))
done < <(deskmngr -l)
out+=("^sep()" " Open config directory,pcmanfm ~/.config/deskmngr/")
out+=("^sep(<i><small>Add new...</small></i>)")
2021-05-21 23:15:53 +02:00
out+=("  <b>New</b> session from current desktop as ...,deskmngr -s")
2021-05-18 16:48:04 +02:00
### RUN
if [ $1 == "-s" ]; then
. /usr/bin/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
MENU_PADDING_TOP=0
MENU_HALIGN="center"
MENU_VALIGN="center"
jgmenu_icon_size=0
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
2021-05-21 23:15:53 +02:00
cat << EOF > ${MENU_ITEMS}
2021-05-18 16:48:04 +02:00
$(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_jgdeskmngr=false;mb-jgtools places"
2021-05-18 16:48:04 +02:00
fi
printf '%s\n' "${out2[@]}"