mabox-colorizer/bin/prtctl

162 lines
4.9 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# prtctl - pyradio theme helper
# TODO start pyradio if not running
THEMERC=~/.config/pyradio/themes/mbcolors.pyradio-theme
2022-08-20 20:51:56 +02:00
CONF_DIR="$HOME/.config/pyradio/"
2023-05-14 14:34:17 +02:00
CONF_FILE="$CONF_DIR/config"
2022-08-16 16:50:11 +02:00
stations() {
sd "^Stations .*$" "Stations $1 $2" ${THEMERC}
}
2022-08-15 01:42:52 +02:00
stations_txt() {
read S SFG SBG<<< "$(grep '^Stations ' ${THEMERC})"
sd "^Stations .*$" "Stations $1 $SBG" ${THEMERC}
}
stations_bg() {
read S SFG SBG<<< "$(grep '^Stations ' ${THEMERC})"
sd "^Stations .*$" "Stations $SFG $1" ${THEMERC}
}
active_station(){
read AS1 AS2 ASFG<<< "$(grep '^Active Station ' ${THEMERC})"
sd "^Active Station .*$" "Active Station $1" ${THEMERC}
}
status_bar() {
read SB1 SB2 SBFG SBBG<<< "$(grep '^Status Bar ' ${THEMERC})"
sd "^Status Bar .*$" "Status Bar $1 $2" ${THEMERC}
}
2022-08-15 01:42:52 +02:00
status_bar_txt() {
read SB1 SB2 SBFG SBBG<<< "$(grep '^Status Bar ' ${THEMERC})"
sd "^Status Bar .*$" "Status Bar $1 $SBBG" ${THEMERC}
}
status_bar_bg() {
read SB1 SB2 SBFG SBBG<<< "$(grep '^Status Bar ' ${THEMERC})"
sd "^Status Bar .*$" "Status Bar $SBFG $1" ${THEMERC}
}
normal_cursor() {
sd "^Normal Cursor .*$" "Normal Cursor $1 $2" ${THEMERC}
}
2022-08-15 01:42:52 +02:00
normal_cursor_txt() {
read NC1 NC2 NCFG NCBG<<< "$(grep '^Normal Cursor ' ${THEMERC})"
sd "^Normal Cursor .*$" "Normal Cursor $1 $NCBG" ${THEMERC}
}
normal_cursor_bg() {
read NC1 NC2 NCFG NCBG<<< "$(grep '^Normal Cursor ' ${THEMERC})"
sd "^Normal Cursor .*$" "Normal Cursor $NCFG $1" ${THEMERC}
}
active_cursor() {
sd "^Active Cursor .*$" "Active Cursor $1 $2" ${THEMERC}
}
2022-08-15 01:42:52 +02:00
active_cursor_txt() {
read AC1 AC2 ACFG ACBG<<< "$(grep '^Active Cursor ' ${THEMERC})"
sd "^Active Cursor .*$" "Active Cursor $1 $ACBG" ${THEMERC}
}
active_cursor_bg() {
read AC1 AC2 ACFG ACBG<<< "$(grep '^Active Cursor ' ${THEMERC})"
sd "^Active Cursor .*$" "Active Cursor $ACFG $1" ${THEMERC}
}
edit_cursor() {
read EC1 EC2 ECFG ECBG<<< "$(grep '^Edit Cursor ' ${THEMERC})"
sd "^Edit Cursor .*$" "Edit Cursor $1 $2" ${THEMERC}
}
2022-08-15 01:42:52 +02:00
edit_cursor_txt() {
read EC1 EC2 ECFG ECBG<<< "$(grep '^Edit Cursor ' ${THEMERC})"
sd "^Edit Cursor .*$" "Edit Cursor $1 $ECBG" ${THEMERC}
}
edit_cursor() {
read EC1 EC2 ECFG ECBG<<< "$(grep '^Edit Cursor ' ${THEMERC})"
sd "^Edit Cursor .*$" "Edit Cursor $ECFG $1" ${THEMERC}
}
extra_func() {
sd "^Extra Func .*$" "Extra Func $1" ${THEMERC}
}
pyradio_url() {
sd "^PyRadio URL .*$" "PyRadio URL $1" ${THEMERC}
}
messages_border() {
sd "^Messages Border .*$" "Messages Border $1" ${THEMERC}
}
2022-08-16 16:50:11 +02:00
resettheme () {
mkdir -p ~/.config/pyradio/themes
cat <<EOF > ${THEMERC}
# Main foreground and background
Stations #309552 #142C2C
# Playing station text color
# (background color will come from Stations)
Active Station #cdc76d
# Status bar foreground and background
Status Bar #cdc76d #22564b
# Normal cursor foreground and background
Normal Cursor #0c1d23 #74885a
# Cursor foreground and background
# when cursor on playing station
Active Cursor #1a231a #cdc76d
# Cursor foreground and background
# This is the Line Editor cursor
Edit Cursor #eed6aa #1a231a
# Text color for extra function indication
# and jump numbers within the status bar
# (background color will come from Stations)
Extra Func #22564b
# Text color for URL
# (background color will come from Stations)
PyRadio URL #d2cda1
# Message window border foreground
# (background color will come from Stations)
Messages Border #d3d4bf
2023-05-14 14:34:17 +02:00
# Theme Transparency
# Values are:
# 0: No transparency (default)
# 1: Theme is transparent
# 2: Obey config setting
transparency 0
2022-08-16 16:50:11 +02:00
EOF
}
2022-08-20 20:51:56 +02:00
export_theme () {
DATE=$(date +'%Y%m%d-%H-%M-%S')
cp ${THEMERC} "$HOME/.config/pyradio/themes/exported_${DATE}.pyradio-theme"
2023-05-17 00:04:59 +02:00
notify-send.sh -i radio "PyRadio theme exported!" "\nNew PyRadio theme created as:\n<b>exported_${DATE}.pyradio-theme</b>\n" -o " Open in editor:xdg-open ${CONF_DIR}/themes/exported_${DATE}.pyradio-theme" -o " Open Themes dir:xdg-open ${CONF_DIR}/themes"
2022-08-20 20:51:56 +02:00
}
2022-08-16 16:50:11 +02:00
#run
if [ ! -f $THEMERC ]; then
resettheme
fi
case "$1" in
stations) stations "$2" "$3";;
2022-08-15 01:42:52 +02:00
stations_txt) stations_txt "$2";;
stations_bg) stations_bg "$2";;
active_station) active_station "$2";;
status_bar) status_bar "$2" "$3";;
2022-08-15 01:42:52 +02:00
status_bar_txt) status_bar_txt "$2";;
status_bar_bg) status_bar_bg "$2";;
normal_cursor) normal_cursor "$2" "$3";;
2022-08-15 01:42:52 +02:00
normal_cursor_txt) normal_cursor_txt "$2";;
normal_cursor_bg) normal_cursor_bg "$2";;
active_cursor) active_cursor "$2" "$3";;
2022-08-15 01:42:52 +02:00
active_cursor_txt) active_cursor_txt "$2";;
active_cursor_bg) active_cursor_bg "$2";;
edit_cursor) edit_cursor "$2" "$3";;
2022-08-15 01:42:52 +02:00
edit_cursor_txt) edit_cursor_txt "$2";;
edit_cursor_bg) edit_cursor_bg "$2";;
extra_func) extra_func "$2";;
pyradio_url) pyradio_url "$2";;
messages_border) messages_border "$2";;
2022-08-16 16:50:11 +02:00
resettheme) resettheme;;
2022-08-20 20:51:56 +02:00
exp) export_theme;;
*);;
esac