Switch color schemes via command line?

So I recently have deicided that I want my color scheme (not my theme) to change with a command, is this possible in any way shape or form without restarting?

1 Like

Far as I remember colour scheme does not need a reboot,
I have to Q : why is rebooting such a (seems like) big problem ?

You can use plasma-apply-colorscheme to change color scheme from the command line. See plasma-apply-colorscheme --help for all the options.

From my quick testing it doesn’t look like you need to reboot, but maybe restart some applications.
If this does not work for you, try to logout and log back in instead of rebooting your whole system.

Looks like logging out and logging back in is required. Maybe the systemd softreboot feature works? I haven’t look into that one.

1 Like

Just tried it, doesnt seem to need a reboot :thinking:, it does work though
Do you think that this will work in cron?

Cron in like the time daemon?

Are you trying to switch between dark and light themes based on time? If so there might be better options.

I feel like we have a XY problem - Wikipedia
Can you tell me what you want to achieve?

# set theme colors
*   6   *   *   *   plasma-apply-colorscheme BreezeClassic
*   19   *   *   *   plasma-apply-colorscheme BreezeDark

Yin-Yang may offer all you need. It can toggle more settings beyond plasma-apply-colorscheme and can switch from the command line (yin-yang toggle toggles settings, yin-yang systemd sets to the systemd timer settings.) Can also run custom scripts for more changes.

So this was a thing I researched before but I decided that it would be too much work for me to deal with and I decided that I wanted to make my own theme switcher since a full GUI is a little extra for me

#!/usr/bin/env bash

if [ date +%k>17 ]; then
	plasma-apply-colorscheme BreezeDark
	plasma-apply-colorscheme BreezeClassic
but unfortunately something doesnt work since i am terrible at bash
theme.sh: line 1: #!/usr/bin/env: No such file or directory
theme.sh: line 3: [: date: unary operator expected
The requested theme "BreezeClassic" is already set as the theme for the current Plasma session
1 Like

Check where you bash is,

$ which bash

then use its path, e.g.

#! /usr/bin/bash

Also, you need a space after the hashbang.

upon doing that i received this error

theme.sh: line 1: #!: command not found

You might want to use this as an inspiration for your script:

if [ `date +%k` -gt 17 ]; then echo "it's late"; fi

Is the space after your shebang normal? Typically I run my commands w/ #!/bin/bash w/o issue

D**n! you are right. I never thought it was optional, but it is.

1 Like

response to @Kwizzz :
So that seems to have fixed my main issue of the script having trouble with time
other response :
The other issue I am seeing is that the shebang is interpreted as a command, could this be a setting I accidentally touched?