[Linux] Changing theme via command line
-
Hello,
I would like to know wether there is a possibility to reload Vivaldis GUI via the command line without restarting Vivaldi. It should be possible since changing themes in Vivaldi only takes a single click. If the command line could be used for this, the theme could be changed/reloaded using scripts. Inspecting the theme chooser dialog, I was able to see that there is a javascript function invoked on pressing the button on a theme, however the javascript file is minified.
-
@Wismut You can easily beautify Vivaldi's javascript files, but it won't help you much. The variables are all single letters and it's hard to see through. It's possible to manipulate themes directly through a mod, but I don't see a way to do this from the command line. Maybe someone else chimes in, also depends on your operating system probably.
-
You could use javascript to manually change the theme colours. I'm not sure how to actually change the theme via js though.
Add for changing it via the command line, im unsure how to do that. Maybe setting up a Web socket listener on the local network, and connecting it via a command line application?
-
Thank you for your answers
What I want to do is to change vivaldis colours based on the current wallpaper. I've copy-pasted/partly written myself a little bash script to cycle my wallpapers, get a colour scheme from it and to apply it to my most frequently used applications. It works fine with Vivaldi too, however, the colour is decided at the start-up of Vivaldi and does not change if the wallpaper is changed.
Changing the theme colours using javascript sounds like a good idea, even though I also don't know how to do it. I could have a file that Vivaldi's modified javascript reads every second and if there is a change, adapts the colours, but using a web socket listener seems like a good idea too, depending on how complicated the implementation is. -
If it's tied to your current wallpaper, it might be possible to use the functionality vivaldi offers through the "Desktop Wallpaper" option from the start page settings.
It can be accessed via the URL
chrome://vivaldi-data/desktop-image/01
.It might be possible to port your colour picker over to javascript, and check against this image, and change the themes according to a set interval.
-
I'm afraid that there is no such option in Vivaldi on linux as there is many ways to set a wallpaper in linux. I just checked on my window installation, where such an option seems to be present.
-
@Wismut That's a pity. I wonder if you could do it this way:
- Run your script to change colours
- Whenever a change is needed, write a css file that overrides the colour variables for themes to your resources directory (e.g. in
C:\Program Files\Vivaldi\Application\2.3.1440.37\resources\vivaldi
) - Then, in vivaldi have a script that, at a set interval, deletes and reloads a
<link>
that points to this css file.
That's a bit messier than changing a theme, or running a single command to reload vivaldi, but it would work.
-
Also just to add, if you look at
chrome.storage.local
, there is a storage key for themes. I'm not sure how those work, but you could give them a try. -
@LonM That's interesting, where do you see that? I can even see an entry for mail in local storage, but not for themes⦠which makes not much sense.
-
@luetage
chrome.storage.local.get(console.log)
shows this: -
@LonM Very nice. Well, we can set the theme from console, that's for sure. A simple
chrome.storage.local.set({'THEME_CURRENT': 'theme_name'});
will do the trick. The only issue is it doesn't update the current window, a new window has to be opened to trigger the theme change on all windows.This should help to issue the command via command line: https://github.com/sidorares/crconsole. I guess a new window could be opened and closed from command line to trigger the theme change.
-
Eh, and turns out there is no trigger needed at all, if you change the color variables of the current theme in local storage directly β this solves the problem, the change is immediate.
-
Thank you both for your great help! I'll try it out when I find some time
-
@luetage I followed your instructions, install node.js. npm and crconsole and was able to start vivaldi with the remote-debugging-port option, but I believe Vivaldi refuses to open the port to connect to crconsole as crconsole just puts out
Error: connect ECONNREFUSED 127.0.0.1:9222 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1104:14)
Did I miss a command or setting in Vivaldi?
EDIT: Got it working. Apparently, all windows need to be closed first. However, I'm not sure how to use the chrome.storage.local.set function correctly to change values.
-
@Wismut I played around with chrome storage and themes over the last couple of days. You can probably do something similar to this: https://forum.vivaldi.net/topic/34767/random-theme-button
The code changes the current theme and sets all active theme variables to the new theme specifications in local chrome storage. The second step is needed to circumvent having to open a new window. The javascript code should work in crconsole, but of course I haven't tested this.
-
@luetage Thank you. I tried it, but I feel like I am doing something wrong as I always get a TypeError when issuing
chrome.storage.local.set({'THEME_CURRENT': 'BL2'})
where BL2 is the name of the theme I want to set it to (just to test it, I will then switch to changing the colours of the theme directly as you stated it will then apply the new colours directly).
-
@Wismut The code is correct and it works in Vivaldi devtools console. Not sure what's going wrong : /
-
I believe I know what the issue is. Crconsole connects you to the console of the page, not the browser itself β this will give you the type error. Try to run with
βremote-debugging-port=2015
instead. -
@luetage I got it working, even though it does not have to do with changing the console port. I ran vivaldi with its remote-debugging flag enabled and the port set to 9222 and connected to it using crconsole, looked at the list of tabs it gave me, where a tab called browser.html was active. I switched to it, issued the command to change the BROWSER_COLOR_ACCENT_BG and it worked! Thank you so much!
-
@Wismut Let us know how it goes and please share your code when you're done. It's a nice project.