mabox-colorizer/bin/colorizer-pyradio

187 lines
8.0 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2022-08-15 01:42:52 +02:00
# TODO Start Pyradio if not started
# TODO check if theme is writeable (users themes)
# TODO Save as new theme
2022-08-16 16:50:11 +02:00
me="colorizer-pyradio -s"
2022-08-15 01:42:52 +02:00
THEMERC=~/.config/pyradio/themes/mbcolors.pyradio-theme
case "$LANG" in
pl*)
2022-08-20 20:51:56 +02:00
COLORIZE_PYRADIO="Pokoloruj PyRadio"
2022-08-16 16:50:11 +02:00
START_PYRADIO="Uruchom PyRadio"
INFO="Info"
INFO_HEAD="Jak działa automatyczna zmiana kolorów?"
INFO_TXT="Automatyczna zmiana kolorów działa z motywem <b>mbcolors</b> (User theme).\nAby go ustawić:\n- użyj klawisza <b>t</b> - wybór motywów\n- zaznacz motyw <i>mbcolors</i> i naciśnij <b>spację</b> - (ustawia jako domyślny)\n- wciśnij <b>c</b> - aby włączyć śledzenie zmian w pliku motywu.\n\n"
GENERATEFROMWP="Generuj z kolorów tapety..."
LIGHTBG="Jasne tło"
DARKBG="Ciemne tło"
2022-08-15 01:42:52 +02:00
SETCOLORS="Ustaw kolory..."
2022-08-20 20:51:56 +02:00
RESETTHEME="Resetuj motyw"
EXPORTTHEME="Eksportuj obecne kolory jako nowy motyw"
CONFIG_AND_DOCS="Konfiguracja i Dokumentacja"
README="PyRadio CZYTAJTO"
MANUAL="Manual PyRadio"
EDITCONF="Edytuj plik konfiguracyjny"
EDITSTATIONS="Edytuj listę stacji"
CONFIGDIR="Katalog z konfiguracją"
;;
*)
2022-08-20 20:51:56 +02:00
COLORIZE_PYRADIO="Colorize PyRadio"
2022-08-16 16:50:11 +02:00
START_PYRADIO="Start PyRadio"
INFO="Info"
INFO_HEAD="How it works?"
INFO_TXT="Automatic theme generation works with <b>mbcolors</b> user theme.\n Configuration:/n- use <b>t</b> key to show theme selection dialog\n- navigate to <i>mbcolors</i> theme and press <b>c</b>\n\n"
GENERATEFROMWP="Generate from wallpaper colors..."
LIGHTBG="Light Background"
DARKBG="Dark Background"
2022-08-15 01:42:52 +02:00
SETCOLORS="Set colors individually..."
2022-08-20 20:51:56 +02:00
RESETTHEME="Reset theme"
EXPORTTHEME="Export current colors as new theme"
CONFIG_AND_DOCS="Config and Docs"
README="PyRadi README"
MANUAL="PyRadio Manual"
EDITCONF="Edit config file"
EDITSTATIONS="Edit stations list"
CONFIGDIR="Config Dir"
;;
esac
2022-08-15 01:42:52 +02:00
getvalues () {
read S SFG SBG<<< "$(grep '^Stations ' ${THEMERC})"
read AS1 AS2 ASFG<<< "$(grep '^Active Station ' ${THEMERC})"
read SB1 SB2 SBFG SBBG<<< "$(grep '^Status Bar ' ${THEMERC})"
read NC1 NC2 NCFG NCBG<<< "$(grep '^Normal Cursor ' ${THEMERC})"
read AC1 AC2 ACFG ACBG<<< "$(grep '^Active Cursor ' ${THEMERC})"
read EC1 EC2 ECFG ECBG<<< "$(grep '^Edit Cursor ' ${THEMERC})"
read EF1 EF2 EFFG<<< "$(grep '^Extra Func ' ${THEMERC})"
read PURL1 PURL2 PURLFG<<< "$(grep '^PyRadio URL ' ${THEMERC})"
read MB1 MB2 MBFG<<< "$(grep '^Messages Border ' ${THEMERC})"
2022-08-15 01:42:52 +02:00
}
getvalues
2022-08-20 20:51:56 +02:00
out+=("^sep($COLORIZE_PYRADIO)")
2022-12-03 18:44:36 +01:00
#out+=("$START_PYRADIO,terminator --geometry=420x440-20-20 -e pyradio")
2022-08-16 16:50:11 +02:00
out+=("$INFO,notify-send.sh -i music '$INFO_HEAD' '$INFO_TXT' -t 20000")
out+=("^sep($GENERATEFROMWP)")
out+=("$LIGHTBG,w2theme pyradio light;$me")
out+=("$DARKBG,w2theme pyradio dark;$me")
2022-08-15 01:42:52 +02:00
out+=("^sep($SETCOLORS)")
out+=("<tt><span weight='bold' bgcolor='$SBG' fgcolor='$SFG'> AbCd </span></tt> Stations,^checkout(stations)")
out2+=("^tag(stations)")
out2+=("^sep(Stations)")
out2+=("Stations Text,^pipe(mbclr '$SFG' prtctl stations_txt 'Stations Text' '$me')")
out2+=("Stations Background,^pipe(mbclr '$SBG' prtctl stations_bg 'Stations Background' '$me')")
out+=("<tt><span weight='bold' bgcolor='$SBG' fgcolor='$ASFG'> AbCd </span></tt> Active Station (text),^pipe(mbclr '$ASFG' prtctl active_station ACTIVE_STATION '$me')")
out+=("<tt><span weight='bold' bgcolor='$NCBG' fgcolor='$NCFG'> AbCd </span></tt> Normal Cursor,^checkout(normalcursor)")
out2+=("^tag(normalcursor)")
out2+=("^sep(Normal Cursor)")
out2+=("Normal Cursor Text,^pipe(mbclr '$NCFG' prtctl normal_cursor_txt 'Normal Cursor Text' '$me')")
out2+=("Normal Cursor Background,^pipe(mbclr '$NCBG' prtctl normal_cursor_bg 'Normal Cursor Background' '$me')")
out+=("<tt><span weight='bold' bgcolor='$ACBG' fgcolor='$ACFG'> AbCd </span></tt> Active Cursor,^checkout(activecursor)")
out2+=("^tag(activecursor)")
out2+=("^sep(Active Cursor)")
out2+=("Active Cursor Text,^pipe(mbclr '$ACFG' prtctl active_cursor_txt 'Active Cursor Text' '$me')")
out2+=("Active Cursor Background,^pipe(mbclr '$ACBG' prtctl active_cursor_bg 'Active Cursor Background' '$me')")
out+=("<tt><span weight='bold' bgcolor='$ECBG' fgcolor='$ECFG'> AbCd </span></tt> Edit Cursor,^checkout(editcursor)")
out2+=("^tag(editcursor)")
out2+=("^sep(Edit Cursor)")
out2+=("Edit Cursor Text,^pipe(mbclr '$ECFG' prtctl edit_cursor_txt 'Edit Cursor Text' '$me')")
out2+=("Edit Cursor Background,^pipe(mbclr '$ECBG' prtctl edit_cursor_bg 'Edit Cursor Background' '$me')")
out+=("<tt><span weight='bold' bgcolor='$SBBG' fgcolor='$SBFG'> AbCd </span></tt> Status Bar,^checkout(statusbar)")
out2+=("^tag(statusbar)")
out2+=("^sep(Status Bar)")
out2+=("Status Bar Text,^pipe(mbclr '$SBFG' prtctl status_bar_txt 'Status Bar Text' '$me')")
out2+=("Status Bar Background,^pipe(mbclr '$SBBG' prtctl status_bar_bg 'Status Bar Background' '$me')")
out+=("<tt><span weight='bold' bgcolor='$SBG' fgcolor='$EFFG'> AbCd </span></tt> Extra Func,^pipe(mbclr '$EFFG' prtctl extra_func EXTRA_FUNC '$me')")
out+=("<tt><span weight='bold' bgcolor='$SBG' fgcolor='$PURLFG'> AbCd </span></tt> PyRadio URL,^pipe(mbclr '$PURLFG' prtctl pyradio_url 'PyRadio URL' '$me')")
out+=("<tt><span weight='bold' bgcolor='$SBG' fgcolor='$MBFG'> AbCd </span></tt> Messages Border,^pipe(mbclr '$MBFG' prtctl messages_border 'Messages Border' '$me')")
2022-08-20 20:51:56 +02:00
out+=("^sep()")
2022-08-27 18:52:55 +02:00
out+=(" $RESETTHEME,prtctl resettheme;$me")
2022-08-20 20:51:56 +02:00
out+=("^sep()")
out+=("$EXPORTTHEME,prtctl exp;$me")
out+=("^sep($CONFIG_AND_DOCS)")
#out+=("PyRadio README,cat /usr/share/doc/pyradio/README.html| yad --html --no-buttons --no-escape --height=800 --width=600")
out+=(" $README,xdg-open /usr/share/doc/pyradio/README.html")
out+=(" $MANUAL,^term(man pyradio)")
out+=("^sep()")
out+=(" $EDITCONF,xdg-open ~/.config/pyradio/config")
out+=(" $EDITSTATIONS,xdg-open ~/.config/pyradio/stations.csv")
out+=("^sep()")
out+=(" $CONFIGDIR,^pipe(jgbrowser ~/.config/pyradio)")
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
2022-08-16 16:50:11 +02:00
CNF_DIR="$HOME/.config/colorizer"
CNF_FILE="$CNF_DIR/colorizer.conf"
source "$CNF_FILE"
out+=("^sep()")
2022-08-20 20:51:56 +02:00
out+=(" ⮜⮜⮜ Colorizer,colorizer -s")
2022-08-16 16:50:11 +02:00
if [[ "$colorizer_size" == "full" ]];then
eval $(xdotool getdisplaygeometry --shell)
MENU_HEIGHT_MIN="$HEIGHT"
MENU_HEIGHT_MAX=$MENU_HEIGHT_MIN
2022-12-03 18:44:36 +01:00
jgtools_radius=0
2022-08-16 16:50:11 +02:00
menu_margin_x="0"
else
MENU_VALIGN="center"
menu_margin_x=${submenu_spacing:-0}
fi
2022-08-16 16:50:11 +02:00
MENU_HALIGN="left"
jgmenu_icon_size=0
2022-08-16 16:50:11 +02:00
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
JGWIDTH=$((jgtools_padding + 278 + jgtools_padding))
MENU_PADDING_TOP=$((jgtools_padding + 158))
#WALLPAPER
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/}
THUMBDIR="$HOME/.config/mabox/wallthumbs"
mkdir -p ${THUMBDIR}
THUMB="${THUMBDIR}/${WALLPAPER}.png"
if [[ ! -f "$THUMB" ]]
then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,${THUMB}
#@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,/usr/share/mabox-colorizer/img/colorizer-conky.png
2022-08-15 01:42:52 +02:00
@rect,,$((jgtools_padding + 144)),$((jgtools_padding + 122)),120,30,4,left,top,#FFFFFF 60,#222222 80,
@text,,$((jgtools_padding + 150)),$((jgtools_padding + 122)),120,30,0,left,top,#FFFFFF,${WINCLR}, <b>PyRadio</b>
$(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[@]}"
2022-08-15 01:42:52 +02:00
printf '%s\n' "${out2[@]}"