154 lines
4.8 KiB
Bash
Executable File
154 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# jgdeskmngr - pipemenu for deskmngr
|
|
#
|
|
|
|
SESSIONDIR="$HOME/.config/deskmngr/"
|
|
CONFIG_FILE="$SESSIONDIR/deskmngr.conf"
|
|
mkdir -p $SESSIONDIR
|
|
# If config file not exist create one with defaults
|
|
if [ ! -f $CONFIG_FILE ]; then
|
|
cat <<EOF > ${CONFIG_FILE}
|
|
waitsec=1
|
|
EOF
|
|
fi
|
|
source <(grep = $CONFIG_FILE)
|
|
waittime=${waitsec:-1}
|
|
|
|
case $LANG in
|
|
pl*)
|
|
REMOVE="Usuń to menu z panelu"
|
|
DESKMNGR="Menadżer sesji desktopowych"
|
|
ABOUT="O DeskMngr"
|
|
SAVED_SESS="Zapisane sesje"
|
|
RESTORE_TO="Przywróć na pulpit..."
|
|
OVERWRITE="<b>Nadpisz</b> sesję:"
|
|
EDIT="<b>Edytuj</b> sesję:"
|
|
DELETE="<b>Usuń</b> sesję:"
|
|
OPEN_CNFDIR="Otwórz katalog z sesjami"
|
|
ADD="Dodaj nową..."
|
|
NEW="<b>Nowa</b> sesja z bieżącego pulpitu jako..."
|
|
SETTINGS="Ustawienia"
|
|
INTERVAL="Interwał"
|
|
title="DeskMngr - zapisuje i przywraca sesje"
|
|
help='\nZapisuje rozmiar i pozycję wszystkich okien z bieżącego pulpitu.\n\nSesję możesz otworzyć poźniej na dowolnym pulpicie.\n\n'
|
|
LEFTPANEL="Lewy panel"
|
|
;;
|
|
es*)
|
|
REMOVE="Eliminar este menú del panel"
|
|
DESKMNGR="Desktop session Manager"
|
|
ABOUT="About DeskMngr"
|
|
SAVED_SESS="Saved sessions"
|
|
RESTORE_TO="Restore to desktop..."
|
|
OVERWRITE="<b>Overwrite</b> session:"
|
|
EDIT="<b>Edit</b> session:"
|
|
DELETE="<b>Delete</b> session:"
|
|
OPEN_CNFDIR="Open config directory"
|
|
ADD="Add new..."
|
|
NEW="<b>New</b> session from current desktop as..."
|
|
SETTINGS="Settings"
|
|
INTERVAL="Interval"
|
|
title="DeskMngr - save and restore sessions"
|
|
help='\nSave all opened windows from active desktop as session.\n\nRestore saved session later on desktop of your choice.\n\n'
|
|
LEFTPANEL="Left panel"
|
|
;;
|
|
*)
|
|
REMOVE="Remove this menu from panel"
|
|
DESKMNGR="Desktop session Manager"
|
|
ABOUT="About DeskMngr"
|
|
SAVED_SESS="Saved sessions"
|
|
RESTORE_TO="Restore to desktop..."
|
|
OVERWRITE="<b>Overwrite</b> session:"
|
|
EDIT="<b>Edit</b> session:"
|
|
DELETE="<b>Delete</b> session:"
|
|
OPEN_CNFDIR="Open config directory"
|
|
ADD="Add new..."
|
|
NEW="<b>New</b> session from current desktop as..."
|
|
SETTINGS="Settings"
|
|
INTERVAL="Interval"
|
|
title="DeskMngr - save and restore sessions"
|
|
help='\nSave all opened windows from active desktop as session.\nRestore saved session later on desktop of your choice.\n\n'
|
|
LEFTPANEL="Left panel"
|
|
;;
|
|
esac
|
|
|
|
me="jgdeskmngr -s"
|
|
|
|
SESSIONDIR="$HOME/.config/deskmngr/"
|
|
mkdir -p $SESSIONDIR
|
|
|
|
out+=("^sep($DESKMNGR)")
|
|
out+=("$ABOUT,\"\"\"notify-send.sh -u critical -i mbcc '$title' '$help';$me\"\"\"")
|
|
|
|
|
|
out+=("^sep(<i><small>$SAVED_SESS</small></i>)")
|
|
i="0"
|
|
while IFS= read -r line
|
|
do
|
|
name=$(basename $line .desk)
|
|
out+=(" ${name//_/ },^checkout(sess${i})")
|
|
out2+=("^tag(sess${i})")
|
|
out2+=("^sep($RESTORE_TO)")
|
|
while IFS= read -r linia || [ -n "$linia" ];
|
|
do read -r ID dname< <(echo $linia)
|
|
dname=$(wmctrl -d | grep ^${ID} | cut -d' ' -f13-)
|
|
out2+=("\"\"\" ${dname/&/&}\"\"\",deskmngr -r $name.desk $ID")
|
|
done < <(wmctrl -d|awk '{print $1}')
|
|
out2+=("^sep()" " $OVERWRITE <b>${name//_/ }</b>,deskmngr save $name")
|
|
out2+=("^sep()" " $EDIT <b>${name//_/ }</b>,xdg-open $SESSIONDIR$name.desk")
|
|
out2+=("^sep()" " $DELETE <b>${name//_/ }</b>,rm -f $SESSIONDIR$name.desk;$me")
|
|
((i=i+1))
|
|
done < <(deskmngr -l)
|
|
|
|
out+=("^sep()" " $OPEN_CNFDIR,pcmanfm ~/.config/deskmngr/")
|
|
out+=("^sep(<i><small>$ADD</small></i>)")
|
|
out+=(" $NEW,deskmngr -s")
|
|
out+=("^sep($SETTINGS)")
|
|
out+=("$INTERVAL: <b>[ $waittime ]</b> ,^checkout(time)")
|
|
out2+=("^tag(time)")
|
|
out2+=("^sep($INTERVAL)")
|
|
for i in 1 2 3 4 5; do out2+=("$(printf "<tt>%3s</tt>,%s" "$i" "mb-setvar waitsec=${i} $CONFIG_FILE;$me")");done
|
|
### RUN
|
|
if [ $1 == "-s" ]; then
|
|
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
|
|
. $HOME/.config/mabox/mabox.conf
|
|
|
|
out+=("^sep()")
|
|
out+=(" ⮜ $LEFTPANEL,mb-jgtools places")
|
|
|
|
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
|
|
MENU_PADDING_TOP=${jgtools_padding:-0}
|
|
MENU_HALIGN="left"
|
|
jgmenu_icon_size=0
|
|
menu_margin_x=${submenu_spacing:-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()"
|
|
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdeskmngr=false;mb-jgtools places"
|
|
fi
|
|
printf '%s\n' "${out2[@]}"
|