#!/bin/bash
# jgdesktops
#
COLORIZER_CONF="$HOME/.config/colorizer/colorizer.conf"
source ${COLORIZER_CONF}
me="jgdesktops -s"
case $LANG in
pl*)
TITLE="Pulpity i Okna"
REMOVE="Usuń to menu z panelu"
ACTIVE="bieżący"
GOTO="Idź do..."
WINKILL="Zabijacz Okien"
CLOSEALL_GR="Z wdziękiem zamknij wszystkie okna na..."
CLOSEALL="Zamknij wszystkie okna na..."
DESKTOP="Pulpicie"
ALL_DESK="Wszystkich pulpitach"
MANAGE="Pulpity"
ADD="Dodaj nowy"
REMOVE_LAST="Usuń ostatni"
CONKY_TOGGLE="Włącz/Wyłącz Conky"
PICOM_TOGGLE="Włącz/Wyłącz Picom"
DESKMNGR="Menadżer sesji pulpitowych"
WALLCHANGER="Tapeta"
DESKGRID="Desktop Grid"
SCREEN_RES="Ustawienia ekranu"
ENABLE="Włącz"
DISABLE="Wyłącz"
DESK_SERVICES="Usługi pulpitu"
CONKY="Sesja Conky"
PICOM="Picom - kompozytor"
CORTILE="Cortile - tiling manager"
MCORNERS="Krawędzie ekranu"
RUNNING="(uruchomiona)"
STOPPED="(zatrzymana)"
WMTWEAKS="Ulepszenia Menadżera Okien"
SHOW_DESK="Pokaż pulpit - lewy klik"
SWITCH_DESK="Zmień pulpit - kółko myszy"
FOCUS="Fokus podąża za myszą"
WALLPAPER="Tapeta"
TOOLS="Narzędzia"
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="Tak (kliknij aby wyłączyć)"
NOC="Nie (kliknij aby włączyć)"
LIGHTBG="light - jasne tło"
DARKBG="dark - ciemne tło"
;;
es*)
TITLE="Windows & Desktops"
REMOVE="Eliminar este menú del panel"
ACTIVE="active"
GOTO="Go to..."
WINKILL="Windows Killer"
CLOSEALL_GR="Gracefully close all windows on..."
CLOSEALL="Close all windows on..."
DESKTOP="Desktop"
ALL_DESK="All Desktops"
MANAGE="Manage Desktops"
ADD="Add new desktop"
REMOVE_LAST="Remove last desktop"
CONKY_TOGGLE="Conky Toggle"
PICOM_TOGGLE="Picom Toggle"
DESKMNGR="Desktop session Manager"
WALLCHANGER="Wallpaper"
DESKGRID="Desktop Grid"
SCREEN_RES="Screen Settings"
ENABLE="Enable"
DISABLE="Disable"
DESK_SERVICES="Desktop services"
CONKY="Conky session"
PICOM="Picom - compositor"
CORTILE="Cortile - tiling manager"
MCORNERS="Screen Edges - hot corners"
RUNNING="(running)"
STOPPED="(stopped)"
WMTWEAKS="Window Manager tweaks"
SHOW_DESK="Show Desktop on left click"
SWITCH_DESK="Switch Desktop on mousewheel up/down"
FOCUS="Focus follow Mouse"
WALLPAPER="Wallpaper"
TOOLS="Tools"
OBTHEME="Openbox Theme"
MENUPANELS="Menus/Panels"
AUTOGEN_THEMES="Auto theming - 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="Yes (click to disable)"
NOC="No (click to enable)"
LIGHTBG="with light background"
DARKBG="with dark background"
;;
*)
TITLE="Windows & Desktops"
REMOVE="Remove this menu from panel"
ACTIVE="active"
GOTO="Go to..."
WINKILL="Windows Killer"
CLOSEALL_GR="Gracefully close all windows on..."
CLOSEALL="Close all windows on..."
DESKTOP="Desktop"
ALL_DESK="All Desktops"
MANAGE="Manage Desktops"
ADD="Add new desktop"
REMOVE_LAST="Remove last desktop"
DESKMNGR="Desktop session Manager"
CONKY_TOGGLE="Conky Toggle"
PICOM_TOGGLE="Picom Toggle"
WALLCHANGER="Wallpaper"
DESKGRID="Desktop Grid"
SCREEN_RES="Screen settings"
ENABLE="Enable"
DISABLE="Disable"
DESK_SERVICES="Desktop services"
CONKY="Conky session"
PICOM="Picom - compositor"
CORTILE="Cortile - tiling manager"
MCORNERS="Screen Edges - hot corners"
RUNNING="(running)"
STOPPED="(stopped)"
WMTWEAKS="Window Manager tweaks"
SHOW_DESK="Show Desktop on left click"
SWITCH_DESK="Switch Desktop on mousewheel up/down"
FOCUS="Focus follow Mouse"
WALLPAPER="Wallpaper"
TOOLS="Tools"
COLORIZER_SETTINGS="Colorizer Settings"
OBTHEME="Openbox Theme"
MENUPANELS="Menus/Panels"
AUTOGEN_THEMES="Auto theming - 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="Yes (click to disable)"
NOC="No (click to enable)"
LIGHTBG="with light background"
DARKBG="with dark background"
;;
esac
#CSVFILE="$HOME/.config/mabox/jgdesktops-bottom.csv"
# If config file not exist create one with defaults
#if [ ! -f $CSVFILE ]; then
#cat < ${CSVFILE}
#^sep($TOOLS)
# $WALLCHANGER,^pipe(jgwallpaperchanger)
# $DESKGRID,^pipe(jgdeskgrid)
# $DESKMNGR,^pipe(jgdeskmngr)
# $SCREEN_RES - ARandR,arandr
# $SCREEN_RES - LXRandr,lxrandr
#EOF
#fi
out+=("^sep(${TITLE})")
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/&/&})" " $GOTO,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($WINKILL)")
out+=(" $CLOSEALL_GR,^checkout(killwin)")
out2+=("^tag(killwin)" "^sep($CLOSEALL)")
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_DESK,killwindows all")
fi
out+=("^sep($MANAGE)")
desktops=$(wmctrl -d |wc -l)
out+=(" $ADD,wmctrl -n $((desktops+1));$me")
out+=(" $REMOVE_LAST,wmctrl -n $((desktops-1));$me")
out+=("^sep($DESK_SERVICES)")
if pidof conky &>/dev/null; then
out+=(" $CONKY $RUNNING,conky_toggle;$me")
else
out+=(" $CONKY $STOPPED,conky_toggle;$me")
fi
if pidof picom &>/dev/null; then
out+=(" $PICOM $RUNNING,compton_toggle;$me")
else
out+=(" $PICOM $STOPPED,compton_toggle;$me")
fi
if command -v mcorners &> /dev/null;then
if [[ -f /tmp/mcorners.lck ]]; then
out+=(" $MCORNERS $RUNNING,mcorners --stop;$me")
else
out+=(" $MCORNERS $STOPPED,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")
fi
fi
if command -v cortile &> /dev/null;then
if pidof cortile &>/dev/null; then
out+=(" $CORTILE $RUNNING,cortilectl stop;$me")
else
out+=(" $CORTILE $STOPPED,cortilectl start;$me")
fi
fi
[[ "$wall2themes" = "yes" ]] && out+=(" $AUTOGEN_THEMES,^checkout(colsettings)") || out+=(" $AUTOGEN_THEMES,^checkout(colsettings)")
# 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)
out+=("^sep($WMTWEAKS)")
if [[ ! -z "$lclick" ]];then
[[ "$lclick" = "none" ]] && out+=(" $SHOW_DESK,obxml show_desk on") || out+=(" $SHOW_DESK,obxml show_desk off")
fi
if [[ ! -z "$mousewheel" ]];then
[[ "$mousewheel" = "none" ]] && out+=(" $SWITCH_DESK,obxml switch_desk on") || out+=(" $SWITCH_DESK,obxml switch_desk off")
fi
[[ "$focus" = "no" ]] && out+=(" $FOCUS,obxml focus_follow_mouse on") || out+=(" $FOCUS,obxml focus_follow_mouse off")
out+=("^sep($TOOLS)")
out+=(" $WALLCHANGER,^pipe(jgwallpaperchanger)")
out+=(" $DESKGRID,^pipe(jgdeskgrid)")
out+=(" $DESKMNGR,^pipe(jgdeskmngr)")
# COLORIZER_CONF SUBMENU
out2+=("^tag(colsettings)")
out2+=("^sep($GENERATETHEMES)")
[[ "$wall2themes" = "yes" ]] && out2+=(" $YESC,mb-setvar wall2themes=no $COLORIZER_CONF;$me") || out2+=(" $NOC,mb-setvar wall2themes=yes $COLORIZER_CONF;$me")
out2+=("^sep()")
out2+=("$OBTHEME [ ${wall2themes_ob} ],^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 [ ${wall2themes_menu} ],^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 [ ${wall2themes_conky} ],^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 [ ${wall2themes_pyradio} ],^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")
### RUN
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $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
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="center"
if [[ "$1" == "ipc" ]]; then
POSITION_MODE="ipc"
else
POSITION_MODE="pointer"
fi
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[@]}")
$(printf '%s\n' "${out3[@]}")
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_jgdesktops=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"
printf '%s\n' "${out3[@]}"