From a20194c30d7118084c02fbf4eeaaa529dc3fa87e Mon Sep 17 00:00:00 2001 From: Eudaimon Date: Sat, 5 Feb 2022 16:28:42 +0100 Subject: [PATCH] New Plasma functionality for GTK4 should be working now. By default, Plasma scheme is set to NOT honoring. --- imports/import.css | 2 +- imports/import_honor_plasma.css | 2 +- imports/plasma_inactive | 0 toggle_plasma.sh | 84 +++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 imports/plasma_inactive create mode 100755 toggle_plasma.sh diff --git a/imports/import.css b/imports/import.css index 72433a6..b4bb3ae 120000 --- a/imports/import.css +++ b/imports/import.css @@ -1 +1 @@ -import_honor_plasma.css \ No newline at end of file +import_ignore_plasma.css \ No newline at end of file diff --git a/imports/import_honor_plasma.css b/imports/import_honor_plasma.css index 175ed62..4dfebd7 100644 --- a/imports/import_honor_plasma.css +++ b/imports/import_honor_plasma.css @@ -1,6 +1,6 @@ /* This imports current selected theme's colors and then overwrites it with Plasma's colors */ -@import "plasma_colors.css"; +@import "plasma_colors.css"; /*unfortunately if it does not exist, this theme will be broken!*/ @import "../theme_colors.css"; diff --git a/imports/plasma_inactive b/imports/plasma_inactive new file mode 100644 index 0000000..e69de29 diff --git a/toggle_plasma.sh b/toggle_plasma.sh new file mode 100755 index 0000000..ac047ff --- /dev/null +++ b/toggle_plasma.sh @@ -0,0 +1,84 @@ +#! /bin/bash + +THEMES_DIR=color_themes +CSS_LINK_NAME=theme_colors.css +IMPORTS_DIR=imports +IMPORT_FILE=import.css +IMPORT_FILE_HONOR_PLASMA=import_honor_plasma.css +IMPORT_FILE_IGNORE_PLASMA=import_ignore_plasma.css + +PLASMA_ACTIVE=plasma_active +PLASMA_INACTIVE=plasma_inactive + +PLASMA_SOURCE_CSS_FILE=~/.config/gtk-3.0/colors.css +LINK_TO_PLASMA_SOURCE_FILE=plasma_colors.css + +maxParams=1 + +usage() { + + echo -e "Usage: $(basename "$0") [--current-status] \n" >&2 + echo -e "Toggles honoring Plasma's color theme on or off. If there is no color theme for GTK generated by Plasma, it won't be toggled on" >&2 + echo -e "\nOption --current-status tells if the theme is currently honoring Plasma color scheme or not" >&2 + +} + + +if [ $# -gt $maxParams ] +then + echo -e "\nError: Incorrect usage." >&2 + usage + exit 1 +fi + +if [ $# -eq 1 ] +then + if [ $1 = "--current-status" ] + then + [ -e $IMPORTS_DIR/PLASMA_ACTIVE ] && echo -e "The theme is honoring Plasma's color scheme\n" || echo -e "\nThe theme is NOT honoring Plasma's color scheme\n" + exit 0 + else + echo -e "\nError: Incorrect usage." >&2 + usage + exit 1 + fi +fi + + +# Making sure we are in the script's directory, otherwise it's not going to work +SCRIPT_PATH=`realpath "$0"` +SCRIPT_DIR=`dirname "$SCRIPT_PATH"` +cd $SCRIPT_DIR + + + +cd $IMPORTS_DIR + +#if we are honoring Plasma colors... +if [ -e $PLASMA_ACTIVE ] +then + # deactivate it + [ -h $IMPORT_FILE ] && rm $IMPORT_FILE + ln -s $IMPORT_FILE_IGNORE_PLASMA $IMPORT_FILE + rm $PLASMA_ACTIVE + touch $PLASMA_INACTIVE + echo -e "\n Plasma theme honoring toggled OFF (that is: GTK theme will not follow current Plasma color scheme)\n" +else + #before activating Plasma, check if plasma colors.css file exists! + if [ ! -e $PLASMA_SOURCE_CSS_FILE ] + then + echo -e "Could not find Plasma color theme for GTK ($PLASMA_SOURCE_CSS_FILE), so GTK theme will continue not attempting to follow Plasma color scheme. Not doing anything, therefore..." + cd cd $SCRIPT_DIR + exit 2 + fi + [ -h $IMPORT_FILE ] && rm $IMPORT_FILE + ln -s $IMPORT_FILE_HONOR_PLASMA $IMPORT_FILE + + [ -h $LINK_TO_PLASMA_SOURCE_FILE ] && rm $LINK_TO_PLASMA_SOURCE_FILE + ln -s $PLASMA_SOURCE_CSS_FILE $LINK_TO_PLASMA_SOURCE_FILE + + [ -e $PLASMA_INACTIVE ] && rm $PLASMA_INACTIVE + touch $PLASMA_ACTIVE + echo -e "\n Plasma theme honoring toggled ON (that is: GTK theme will follow current Plasma color scheme)\n" +fi +cd $SCRIPT_DIR \ No newline at end of file