deskmngr and desktops pipemenus

master
Daniel Napora 2021-05-18 16:48:04 +02:00
parent 6cf7a294af
commit 202a241940
2 changed files with 149 additions and 0 deletions

63
usr/bin/jgdeskmngr 100755
View File

@ -0,0 +1,63 @@
#!/bin/bash
# jgdeskmngr - pipemenu for deskmngr
#
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)
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/&/&amp;}\"\"\",deskmngr -r $name.desk $ID")
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>)")
out+=(" <b>New</b> 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 <<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_keyspipe=false"
fi
printf '%s\n' "${out2[@]}"

86
usr/bin/jgdesktops 100755
View File

@ -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(<i><small>${dname/&/&amp;} (active)</small></i>)")
else
out+=("^sep(<i><small>${dname/&/&amp;}</small></i>)" "<i>Go to... </i><b>${dname/&/&amp;}</b>,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/&/&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
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/&/&amp;},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 <<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[@]}"
#printf '%s\n' "${out[@]}" > $HOME/.config/mabox/shortkeys.csv
if [[ $1 == "-r" ]]; then
printf '%s\n' "^sep()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_keyspipe=false"
fi
printf '%s\n' "${out2[@]}"