Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-02-18 02:59:50

Ted
Member
Registered: 2016-02-18
Posts: 3

Changing Panel Background Color

Hi there,
I'm setting up my theme and I'm going for a very simplistic look (see screen shot), however, I'm looking to write a quick script to change the panel colors according to which background is currently active. I've found the xfce-panel.xml file and where I can manually change the colors of the panels, but it seems as though in the xml file it is not storing the color as a HEX value as in the panel editor.

For example, my top panel has the HEX color of #81C784, a light green. While the xml file reads:

<property name="panel-1" type="empty">
      <property name="position" type="string" value="p=6;x=683;y=8"/>
      <property name="length" type="uint" value="100"/>
      <property name="position-locked" type="bool" value="false"/>
      <property name="size" type="uint" value="16"/>
      <property name="plugin-ids" type="array">
        <value type="int" value="1"/>
        <value type="int" value="8"/>
        <value type="int" value="11"/>
        <value type="int" value="12"/>
        <value type="int" value="14"/>
        <value type="int" value="16"/>
        <value type="int" value="17"/>
        <value type="int" value="18"/>
        <value type="int" value="3"/>
        <value type="int" value="15"/>
        <value type="int" value="4"/>
        <value type="int" value="21"/>
        <value type="int" value="20"/>
        <value type="int" value="22"/>
        <value type="int" value="6"/>
        <value type="int" value="2"/>
        <value type="int" value="19"/>
        <value type="int" value="5"/>
      </property>
      <property name="background-style" type="uint" value="1"/>
      <property name="background-color" type="array">
        <value type="uint" value="33153"/>
        <value type="uint" value="51143"/>
        <value type="uint" value="33924"/>
        <value type="uint" value="65535"/>
      </property>
      <property name="nrows" type="uint" value="1"/>
      <property name="autohide-behavior" type="uint" value="0"/>
    </property>

How does that hex value translate into those 4 unsigned ints? (33153,51143,33924,65535). Any advice would be appreciated, even if you think I might be going about this all wrong. (Would it just be better to swap out the different xfce4-panel.xml files in the script instead of editing the one?)

Thanks!
Ted

3Fe5dqpl.png

Offline

#2 2016-02-18 03:19:26

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,486

Re: Changing Panel Background Color

Hello and welcome.

I'm looking to write a quick script to change the panel colors according to which background is currently active.

I tried doing something similar here a while ago. I used "convert -extract" to grab an average colour of the image behind the panel and xfconf-query to set the new panel background colour (xfconf-query will change the colours on the fly). Perhaps there is something in that code that you could use.

How does that hex value translate into those 4 unsigned ints? (33153,51143,33924,65535).

GTK/GDK accepts colour values from 0 to 65535 (source). You can divide that number by 256 to get the normal 0-255 colour values (that you can convert to and from hex) and vice versa.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2016-02-18 03:49:21

Ted
Member
Registered: 2016-02-18
Posts: 3

Re: Changing Panel Background Color

I actually did stumble across that script first, however I want to change the panel color to specific values, not just the averages. That source is loads of help! Thanks for the quick response.

Offline

#4 2016-02-18 19:12:07

Ted
Member
Registered: 2016-02-18
Posts: 3

Re: Changing Panel Background Color

ToZ wrote:

I tried doing something similar here a while ago. I used "convert -extract" to grab an average colour of the image behind the panel and xfconf-query to set the new panel background colour (xfconf-query will change the colours on the fly). Perhaps there is something in that code that you could use.

I tried reading through your code, but I can't seem to find the line which tells the panels to reload and change the colors. I was planning on having all of my configurations set in the ~//home/ted/.config/xfce4/xfconf/xfce-perchannel-xml/ folder and have them named like xfce4-panel-green.xml and then when the script wants to change the color theme all it needs to do is rename xfce-panel-green.xml > xfce-panel.xml and then change the xfce-panel.xml (the previous one) to xfce-panel-*.xml.

I've been trying this rudimentary proof of concept where I made two different xfce4-panel.xml files with different configs and then copy/pasted them in/out of the folder and than ran 'xfce4-panel -r' in hopes that it would update the panels, but the previous color still remains even when I remove it completely from the folder. I even tried restarting Xorg and it doesn't change the color.

Thank you!

Offline

#5 2016-02-18 20:43:01

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,486

Re: Changing Panel Background Color

Using xfconf-query is much quicker and more immediate than swapping xml files. In my code, all of the xfconf-query commands are either reading or changing panel properties.

The panel background colour is set in the "xfce4-panel" xfconf channel in the /panels/panel-X/background-color property, where X is the panel number. (Note that this to work, the /panels/panel-X/background-style needs to be set to "1"). If you use xfconf-query, the change is automatic. For example, assuming panel-6:

1. Set the background-style to 1:

xfconf-query -c xfce4-panel -p /panels/panel-6/background-style -s 0

2. Change the background color to say red:

xfconf-query -c xfce4-panel -p /panels/panel-6/background-color -s 65535 -s 0 -s 0 -s 0

...the 4 colour values being set are red, green, blue and the fourth always 0, as 16-bit integer values.

Using xfconf-query will make the change immediately, without the need to load/reload panel xml files or restart xfce4-panel.



I've been trying this rudimentary proof of concept where I made two different xfce4-panel.xml files

If you want to do this with xml files, then with panels its a little more complicated than that. If you're just changing the colours, then the procedure is simpler:
- quit the panel (xfce4-panel -q)
- change the panel xml files
- start the panel (xfce4-panel)
...there will be a noticeable flickering of the panel stopping and restarting. But its the only way to properly set and read the new xml file. You can't just use xfce4-panel -r because it will overwrite your new panel xml file with its current settings as its restarting.
However, if you're also changing the plugins on the panels, then there are more files that may need to saved and restored (in the ~/.config/xfce4/panel folder).

Again, its easier to just use xfconf-query to make immediate changes to the panels.

EDIT: xfconf-query wiki page.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.008 seconds, 7 queries executed - Memory usage: 551.62 KiB (Peak: 568.9 KiB) ]