diff --git a/usr/bin/jgdeskmngr b/usr/bin/jgdeskmngr new file mode 100755 index 0000000..d44a9ea --- /dev/null +++ b/usr/bin/jgdeskmngr @@ -0,0 +1,63 @@ +#!/bin/bash +# jgdeskmngr - pipemenu for deskmngr +# +SESSIONDIR="$HOME/.config/deskmngr/" +mkdir -p $SESSIONDIR + +out+=("^sep(Desktop session Manager)") +out+=("^sep(Saved sessions )") +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 desktop...)") + 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()" "  Edit session: ${name//_/ },geany $SESSIONDIR$name.desk") +out2+=("^sep()" "  Delete session: ${name//_/ },rm -f $SESSIONDIR$name.desk") +((i=i+1)) +done < <(deskmngr -l) + +out+=("^sep()" " Open config directory,pcmanfm ~/.config/deskmngr/") +out+=("^sep(Add new...)") +out+=(" New session from current desktop as ...,deskmngr -s") + + +### 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 + +cat < ${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' "$REMOVE,mb-setvar places_keyspipe=false" +fi +printf '%s\n' "${out2[@]}" diff --git a/usr/bin/jgdesktops b/usr/bin/jgdesktops new file mode 100755 index 0000000..b394f85 --- /dev/null +++ b/usr/bin/jgdesktops @@ -0,0 +1,86 @@ +#!/bin/bash +# jgdesktops +# + + +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 +out+=("^sep(${dname/&/&} (active))") + +else +out+=("^sep(${dname/&/&})" "Go to... ${dname/&/&},wmctrl -s $ID") +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/&/&} ]\"\"\",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 + out+=("^sep(Windows Killer)") + out+=("Gracefully close all windows on...,^checkout(killwin)") + out2+=("^tag(killwin)" "^sep(Close all windows on...)") + for i in $(wmctrl -l | awk $2 '!/-1/ {print $2}' |sort| uniq) + do + dname=$(wmctrl -d | grep ^${i} | cut -d' ' -f13-) + out2+=("Desktop ${dname/&/&},killwindows $i") + done + out2+=("^sep()" "All Desktops,killwindows all") +fi +out+=("^sep(Manage Desktops)") +desktops=$(wmctrl -d |wc -l) +out+=("Add new desktop,wmctrl -n $((desktops+1))") +out+=("Remove last desktop,wmctrl -n $((desktops-1))") +out+=("^sep()") +out+=("Desktop session Manager,jgdeskmngr -s") + + +### 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 + +cat < ${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[@]}" +#printf '%s\n' "${out[@]}" > $HOME/.config/mabox/shortkeys.csv + +if [[ $1 == "-r" ]]; then +printf '%s\n' "^sep()" +printf '%s\n' "$REMOVE,mb-setvar places_keyspipe=false" +fi +printf '%s\n' "${out2[@]}"