mabox-pipemenus/usr/bin/jgdesktops

368 lines
13 KiB
Plaintext
Raw Normal View History

2021-05-18 16:48:04 +02:00
#!/bin/bash
# jgdesktops
#
2023-05-19 00:17:14 +02:00
COLORIZER_CONF="$HOME/.config/colorizer/colorizer.conf"
source ${COLORIZER_CONF}
me="jgdesktops -s"
2021-05-22 02:00:30 +02:00
case $LANG in
pl*)
2023-05-20 16:36:59 +02:00
TITLE="Pulpity i Okna"
2021-05-22 02:00:30 +02:00
REMOVE="Usuń to menu z panelu"
2021-05-31 15:00:35 +02:00
ACTIVE="bieżący"
GOTO="Idź do..."
WINKILL="Zabijacz Okien"
2023-05-03 15:53:23 +02:00
CLOSEALL_GR="Z wdziękiem <b>zamknij wszystkie okna</b> na..."
2021-05-31 15:00:35 +02:00
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>"
CONKY_TOGGLE="Włącz/Wyłącz Conky"
PICOM_TOGGLE="Włącz/Wyłącz Picom"
2021-05-31 15:00:35 +02:00
DESKMNGR="Menadżer sesji pulpitowych"
2022-02-15 22:11:33 +01:00
WALLCHANGER="Tapeta"
DESKGRID="Desktop Grid"
SCREEN_RES="Ustawienia ekranu"
ENABLE="Włącz"
DISABLE="Wyłącz"
2023-05-03 15:53:23 +02:00
DESK_SERVICES="Usługi pulpitu"
2023-06-10 09:46:09 +02:00
TINT2="<b>Tint2 panel</b>"
2023-05-03 15:53:23 +02:00
CONKY="Sesja <b>Conky</b>"
PICOM="<b>Picom</b> - kompozytor"
CORTILE="<b>Cortile</b> - tiling manager"
MCORNERS="<b>Krawędzie ekranu</b>"
RUNNING="(uruchomiona)"
STOPPED="(zatrzymana)"
2023-05-19 00:17:14 +02:00
WMTWEAKS="Ulepszenia Menadżera Okien"
2023-05-18 16:05:29 +02:00
SHOW_DESK="Pokaż pulpit - lewy klik"
SWITCH_DESK="Zmień pulpit - kółko myszy"
FOCUS="Fokus podąża za myszą"
WALLPAPER="Tapeta"
TOOLS="Narzędzia"
2023-05-19 00:17:14 +02:00
OBTHEME="Motyw Openbox"
MENUPANELS="Menu i Panele"
AUTOGEN_THEMES="Autogenerowanie motywów?"
GENERATETHEMES="Generować motywy po zmianie tapety?"
GENOB="Pokolorować Dekoracje Okien?"
GENMENU="Pokolorować menu i panele?"
GENCONKY="Pokolorować Conky?"
GENPYRADIO="Pokolorować PyRadio?"
YES="Tak"
NO="Nie"
YESC="<b>Tak</b> <i>(kliknij aby wyłączyć)</i>"
NOC="<b>Nie</b> <i>(kliknij aby włączyć)</i>"
LIGHTBG="<b>light</b> - jasne tło"
DARKBG="<b>dark</b> - ciemne tło"
2021-05-22 02:00:30 +02:00
;;
es*)
2023-05-20 16:36:59 +02:00
TITLE="Windows &amp; Desktops"
2021-05-22 02:00:30 +02:00
REMOVE="Eliminar este menú del panel"
2021-05-31 15:00:35 +02:00
ACTIVE="active"
GOTO="Go to..."
WINKILL="Windows Killer"
2023-05-03 15:53:23 +02:00
CLOSEALL_GR="Gracefully <b>close all windows</b> on..."
2021-05-31 15:00:35 +02:00
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"
CONKY_TOGGLE="Conky Toggle"
PICOM_TOGGLE="Picom Toggle"
2021-05-31 15:00:35 +02:00
DESKMNGR="Desktop session Manager"
2022-02-15 22:11:33 +01:00
WALLCHANGER="Wallpaper"
DESKGRID="Desktop Grid"
2023-05-18 16:05:29 +02:00
SCREEN_RES="Screen Settings"
ENABLE="Enable"
DISABLE="Disable"
2023-05-03 15:53:23 +02:00
DESK_SERVICES="Desktop services"
2023-06-10 09:46:09 +02:00
TINT2="<b>Tint2 panel</b> session"
2023-05-03 15:53:23 +02:00
CONKY="<b>Conky</b> session"
PICOM="<b>Picom</b> - compositor"
CORTILE="<b>Cortile</b> - tiling manager"
MCORNERS="<b>Screen Edges</b> - hot corners"
RUNNING="(running)"
STOPPED="(stopped)"
2023-05-19 00:17:14 +02:00
WMTWEAKS="Window Manager tweaks"
2023-05-18 16:05:29 +02:00
SHOW_DESK="Show Desktop on left click"
SWITCH_DESK="Switch Desktop on mousewheel up/down"
FOCUS="Focus follow Mouse"
WALLPAPER="Wallpaper"
TOOLS="Tools"
2023-05-19 00:17:14 +02:00
OBTHEME="Openbox Theme"
MENUPANELS="Menus/Panels"
AUTOGEN_THEMES="<b>Auto theming</b> - based on wallp colors"
GENERATETHEMES="Generate themes on wallpaper change?"
GENOB="Colorize Window Decorations?"
GENMENU="Colorize Menus and Panels?"
GENCONKY="Colorize Conky?"
GENPYRADIO="Colorize PyRadio?"
YES="Yes"
NO="No"
YESC="<b>Yes</b> <i>(click to disable)</i>"
NOC="<b>No</b> <i>(click to enable)</i>"
LIGHTBG="with <b>light</b> background"
DARKBG="with <b>dark</b> background"
2021-05-22 02:00:30 +02:00
;;
2023-05-20 16:36:59 +02:00
*)
TITLE="Windows &amp; Desktops"
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"
2023-05-03 15:53:23 +02:00
CLOSEALL_GR="Gracefully <b>close all windows</b> on..."
2021-05-31 15:00:35 +02:00
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"
CONKY_TOGGLE="Conky Toggle"
PICOM_TOGGLE="Picom Toggle"
2022-02-15 22:11:33 +01:00
WALLCHANGER="Wallpaper"
DESKGRID="Desktop Grid"
SCREEN_RES="Screen settings"
ENABLE="Enable"
DISABLE="Disable"
2023-05-03 15:53:23 +02:00
DESK_SERVICES="Desktop services"
2023-06-10 09:46:09 +02:00
TINT2="<b>Tint2 panel</b> session"
2023-05-03 15:53:23 +02:00
CONKY="<b>Conky</b> session"
PICOM="<b>Picom</b> - compositor"
CORTILE="<b>Cortile</b> - tiling manager"
MCORNERS="<b>Screen Edges</b> - hot corners"
RUNNING="(running)"
STOPPED="(stopped)"
2023-05-19 00:17:14 +02:00
WMTWEAKS="Window Manager tweaks"
2023-05-18 16:05:29 +02:00
SHOW_DESK="Show Desktop on left click"
SWITCH_DESK="Switch Desktop on mousewheel up/down"
FOCUS="Focus follow Mouse"
WALLPAPER="Wallpaper"
TOOLS="Tools"
2023-05-19 00:17:14 +02:00
COLORIZER_SETTINGS="Colorizer Settings"
OBTHEME="Openbox Theme"
MENUPANELS="Menus/Panels"
AUTOGEN_THEMES="<b>Auto theming</b> - based on wallp colors"
GENERATETHEMES="Generate themes on wallpaper change?"
GENOB="Colorize Window Decorations?"
GENMENU="Colorize Menus and Panels?"
GENCONKY="Colorize Conky?"
GENPYRADIO="Colorize PyRadio?"
YES="Yes"
NO="No"
YESC="<b>Yes</b> <i>(click to disable)</i>"
NOC="<b>No</b> <i>(click to enable)</i>"
LIGHTBG="with <b>light</b> background"
DARKBG="with <b>dark</b> background"
2021-05-31 15:00:35 +02:00
;;
2021-05-22 02:00:30 +02:00
esac
2021-05-18 16:48:04 +02:00
2023-05-20 16:36:59 +02:00
#CSVFILE="$HOME/.config/mabox/jgdesktops-bottom.csv"
2022-02-15 22:11:33 +01:00
# If config file not exist create one with defaults
2023-05-20 16:36:59 +02:00
#if [ ! -f $CSVFILE ]; then
#cat <<EOF > ${CSVFILE}
#^sep($TOOLS)
#<big>󰸉</big> $WALLCHANGER,^pipe(jgwallpaperchanger)
#<big>󱇙</big> $DESKGRID,^pipe(jgdeskgrid)
#<big></big> $DESKMNGR,^pipe(jgdeskmngr)
#<big>󰹑</big> $SCREEN_RES - ARandR,arandr
#<big>󰹑</big> $SCREEN_RES - LXRandr,lxrandr
#EOF
#fi
2022-02-15 22:11:33 +01:00
2023-05-20 16:36:59 +02:00
out+=("^sep(${TITLE})")
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)")
2023-05-03 15:53:23 +02:00
out+=("<big>󰚌</big> $CLOSEALL_GR,^checkout(killwin)")
2021-05-31 15:00:35 +02:00
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)
out+=("  $ADD,wmctrl -n $((desktops+1));$me")
out+=("  $REMOVE_LAST,wmctrl -n $((desktops-1));$me")
2023-05-18 16:05:29 +02:00
2023-05-03 15:53:23 +02:00
out+=("^sep($DESK_SERVICES)")
2023-06-10 09:46:09 +02:00
if pidof tint2 &>/dev/null;then
#out+=("<big>󰄲</big> $TINT2 <i>$RUNNING</i>,killall tint2;$me")
:
else
out+=("<big>󰄱</big> $TINT2 <i>$STOPPED</i>,mb-tint2-session &>/dev/null;$me")
fi
2022-02-24 18:02:51 +01:00
if pidof conky &>/dev/null; then
2023-05-03 15:53:23 +02:00
out+=("<big>󰄲</big> $CONKY <i>$RUNNING</i>,conky_toggle;$me")
else
2023-05-03 15:53:23 +02:00
out+=("<big>󰄱</big> $CONKY <i>$STOPPED</i>,conky_toggle;$me")
fi
2022-02-24 18:02:51 +01:00
if pidof picom &>/dev/null; then
2023-05-03 15:53:23 +02:00
out+=("<big>󰄲</big> $PICOM <i>$RUNNING</i>,compton_toggle;$me")
else
2023-05-03 15:53:23 +02:00
out+=("<big>󰄱</big> $PICOM <i>$STOPPED</i>,compton_toggle;$me")
fi
2023-05-18 16:05:29 +02:00
if command -v mcorners &> /dev/null;then
if [[ -f /tmp/mcorners.lck ]]; then
out+=("<big>󰄲</big> $MCORNERS <i>$RUNNING</i>,mcorners --stop;$me")
else
2023-05-19 00:17:14 +02:00
out+=("<big>󰄱</big> $MCORNERS <i>$STOPPED</i>,mcorners -tl 'jgdesktops -s' -l 'mb-jgtools places' -tr 'mb-music -s' -bl 'colorizer -s' -br 'skippy-xd-fix' -r 'mb-jgtools right' -iof;$me")
2023-05-18 16:05:29 +02:00
fi
fi
2023-05-19 13:34:32 +02:00
if command -v cortile &> /dev/null;then
2023-05-03 15:53:23 +02:00
if pidof cortile &>/dev/null; then
out+=("<big>󰄲</big> $CORTILE <i>$RUNNING</i>,cortilectl stop;$me")
else
out+=("<big>󰄱</big> $CORTILE <i>$STOPPED</i>,cortilectl start;$me")
fi
fi
2023-05-19 00:17:14 +02:00
[[ "$wall2themes" = "yes" ]] && out+=("<big></big> $AUTOGEN_THEMES,^checkout(colsettings)") || out+=("<big></big> $AUTOGEN_THEMES,^checkout(colsettings)")
2023-05-18 16:05:29 +02:00
# DESKTOP MOUSE ACTIONS
lclick=$(xml sel -N a=http://openbox.org/3.4/rc -t -v '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Press"][@button="Left"]/a:action/@name' $HOME/.config/openbox/rc.xml)
mousewheel=$(xml sel -N a=http://openbox.org/3.4/rc -t -v '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Click"][@button="Up"]/a:action/a:to' $HOME/.config/openbox/rc.xml)
focus=$(xml sel -N a=http://openbox.org/3.4/rc -t -v '/a:openbox_config/a:focus/a:followMouse' $HOME/.config/openbox/rc.xml)
2023-05-19 00:17:14 +02:00
out+=("^sep($WMTWEAKS)")
2023-05-18 16:05:29 +02:00
if [[ ! -z "$lclick" ]];then
[[ "$lclick" = "none" ]] && out+=("<big>󰄱</big> $SHOW_DESK,obxml show_desk on") || out+=("<big>󰄲</big> $SHOW_DESK,obxml show_desk off")
fi
if [[ ! -z "$mousewheel" ]];then
[[ "$mousewheel" = "none" ]] && out+=("<big>󰄱</big> $SWITCH_DESK,obxml switch_desk on") || out+=("<big>󰄲</big> $SWITCH_DESK,obxml switch_desk off")
fi
[[ "$focus" = "no" ]] && out+=("<big>󰄱</big> $FOCUS,obxml focus_follow_mouse on") || out+=("<big>󰄲</big> $FOCUS,obxml focus_follow_mouse off")
2023-05-19 00:17:14 +02:00
out+=("^sep($TOOLS)")
out+=("<big>󰸉</big> $WALLCHANGER,^pipe(jgwallpaperchanger)")
out+=("<big>󱇙</big> $DESKGRID,^pipe(jgdeskgrid)")
out+=("<big></big> $DESKMNGR,^pipe(jgdeskmngr)")
# COLORIZER_CONF SUBMENU
out2+=("^tag(colsettings)")
out2+=("^sep($GENERATETHEMES)")
[[ "$wall2themes" = "yes" ]] && out2+=("<big></big> $YESC,mb-setvar wall2themes=no $COLORIZER_CONF;$me") || out2+=("<big></big> $NOC,mb-setvar wall2themes=yes $COLORIZER_CONF;$me")
out2+=("^sep()")
out2+=("$OBTHEME [ <b>${wall2themes_ob}</b> ],^checkout(ob)")
out3+=("^tag(ob)")
out3+=("^sep($GENOB)")
out3+=("$NO,mb-setvar wall2themes_ob=none $COLORIZER_CONF;$me")
out3+=("^sep()")
out3+=("$LIGHTBG,mb-setvar wall2themes_ob=light $COLORIZER_CONF;$me")
out3+=("$DARKBG,mb-setvar wall2themes_ob=dark $COLORIZER_CONF;$me")
out2+=("$MENUPANELS [ <b>${wall2themes_menu}</b> ],^checkout(mp)")
out3+=("^tag(mp)")
out3+=("^sep($GENMENU)")
out3+=("$NO,mb-setvar wall2themes_menu=none $COLORIZER_CONF;$me")
out3+=("^sep()")
out3+=("$LIGHTBG,mb-setvar wall2themes_menu=light $COLORIZER_CONF;$me")
out3+=("$DARKBG,mb-setvar wall2themes_menu=dark $COLORIZER_CONF;$me")
out2+=("Conky [ <b>${wall2themes_conky}</b> ],^checkout(conky)")
out3+=("^tag(conky)")
out3+=("^sep($GENCONKY)")
out3+=("$NO,mb-setvar wall2themes_conky=none $COLORIZER_CONF;$me")
out3+=("^sep()")
out3+=("$LIGHTBG,mb-setvar wall2themes_conky=light $COLORIZER_CONF;$me")
out3+=("$DARKBG,mb-setvar wall2themes_conky=dark $COLORIZER_CONF;$me")
out2+=("PyRadio [ <b>${wall2themes_pyradio}</b> ],^checkout(pyradio)")
out3+=("^tag(pyradio)")
out3+=("^sep($GENPYRADIO)")
out3+=("$NO,mb-setvar wall2themes_pyradio=none $COLORIZER_CONF;$me")
out3+=("^sep()")
out3+=("$LIGHTBG,mb-setvar wall2themes_pyradio=light $COLORIZER_CONF;$me")
out3+=("$DARKBG,mb-setvar wall2themes_pyradio=dark $COLORIZER_CONF;$me")
#out+=(". ~/.config/mabox/jgdesktops-bottom.csv")
2021-05-18 16:48:04 +02:00
### RUN
2021-11-08 13:35:05 +01:00
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
2021-09-24 01:40:09 +02:00
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
2021-05-18 16:48:04 +02:00
. $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-11-08 13:35:05 +01:00
if [[ "$1" == "ipc" ]]; then
POSITION_MODE="ipc"
2021-11-09 12:26:37 +01:00
else
POSITION_MODE="pointer"
2021-11-08 13:35:05 +01:00
fi
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[@]}")
2023-05-19 00:17:14 +02:00
$(printf '%s\n' "${out3[@]}")
2021-05-18 16:48:04 +02:00
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[@]}"
2023-05-19 00:17:14 +02:00
printf '%s\n' "${out3[@]}"