Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Update native xfce4-panel clock after suspend

Just as the name says, here is where you can post tips and tricks to share with other users of MEPIS.
Post Reply
User avatar
Forum Regular
Forum Regular
Posts: 284
Joined: Sat Mar 31, 2018 6:39 pm

Update native xfce4-panel clock after suspend

#1 Post by rich » Sat May 26, 2018 7:51 am

Note - Before adjusting your panel settings, you may wish to backup your current panel by opening the menu, typing "MX Tweak," checking "Backup current panel configuration," and clicking "Apply." This way you will have the option of restoring your current panel configuration at a later point by checking "Restore backup panel configuration" and clicking "Apply." You may also simply restore the default panel configuration by checking "Restore default panel". These instructions apply to MX 17.1.

On my system, sometimes I prefer to use the "Clock" panel plugin instead of the "Orage Panel Clock" plugin because it supports transparent backgrounds and because of its simpler interface (clicking pops up an attached undecorated calender widget instead of opening the whole orage calender application window.) I noticed, however, system time was not being updated upon resuming from suspend. It would hang displaying whatever the time had been when the system suspended for about a minute or until the clock was moused over or clicked. Thankfully, I was given a great tip over on the xfce forum which I'd like to share here.

It was suggested that the clock could be refreshed, and that this could be triggered by default upon resuming from suspend. The exact commands to refresh the clock may vary, but are fairly simple to determine. There are two parts:

1.) Reset the panel clock to default setting.
2.) Set the clock to user preference setting.

First, we must determine how to refer to the clock in our command. To do so we can open the menu and type "Panel" to open the panel preferences. Click on "Items" and hover your mouse over the "Clock" entry (this is assuming you now have the "Clock" panel item listed instead of or in addition to "Orage Panel Clock.") You should see a tooltip displaying something like, "Internal name: clock-8." The plugin number in our commands will be determined by the number shown in this tooltip.

The following command, using my example of panel item number 8, resets the clock configuration to default:

Code: Select all

xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -r
while the second command reenables and sets a custom date format, in this case using the format %I:%M %p (adjust date format as needed, notice the backslash required to escape whitespace)

Code: Select all

xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -n -t string -s %I:%M\ %p
These commands can be strung together like so

Code: Select all

xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -r && xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -n -t string -s %I:%M\ %p"
Go ahead and try it out in the terminal to confirm it's working and test your date format.

Next, we need to tell the system to run this command upon resume from suspend. In MX Linux, we can place a small script in the /etc/pm/sleep.d/ directory. I have named mine 00_xfclock, so the full name for the following file could be /etc/pm/sleep.d/00_xfclock.

Code: Select all

case $1 in
		DISPLAY=:0 ; export DISPLAY
		su rich -c "
		/usr/bin/xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -r && \
		/usr/bin/xfconf-query -c xfce4-panel -p /plugins/plugin-8/digital-format -n -t string -s %I:%M\ %p &"
In this example, I have used my own username. Please swap "rich" with whatever your username is. As root, add this file and make it executable with the command

Code: Select all

chmod +x /etc/pm/sleep.d/00_xfclock
Now you can enjoy a little transparency in your panel clock without waiting around for the time to update after a suspend!
MX 17.1 Dell Inspiron N5110

Post Reply

Return to “Tips&Tricks”