Xfce4 Timer Tutorial(s)

by TheOuterLinux (https://theouterlinux.gitlab.io)

Last updated: 2023/09/12

[ Click to visit TheOuterLinux's 'Support Me' page ] [ QRCode ] [ RSS ]

Table of Contents

  1. How to get the Xfce4 Timer to run a command/alarm on a specific day of the week
    1. Step 01: Adding the Xfce4 Timer to the panel
    2. Step 02: Adding timers
    3. Step 03: Making it all work...

How to get the Xfce4 Timer to run a command/alarm on a specific day of the week

By default, the package 'xfce4-timer', version 1.7.1-1, currently only allows you to create timers based on hours, minutes, and seconds, or a specific time of the day. HOWEVER, with the help of the 'date' command, you can use a BASH script to help you to only run what you need on a particular day of the week. By the way, the theme seen in the screenshots is called "Matcha-dark-sea" (sudo apt install matcha-themes).

Step 01: Adding the Xfce4 Timer to the panel

If you already have the xfce4-timer added to your XFCE panel, you can skip to Step 2.

If you do not have the Xfce4 Timer on your XFCE panel, right-click the panel and use "Panel --> Add New Items"

Then, use the search area to look for "Xfce4 Timer" and click the "Add" button.

Step 02: Adding timers

It may be hard to see, but after adding the 'Xfce4 Timer' to the panel, there will be an item that may look like a tiny, empty loading bar. Right-click this item and select "Properties." You will know if you have right-clicked the correct applet if the right-click menu says "Xfce4 Timer."

After clicking "Properties," you will see a window titled as "Xfce4 Timer Options" like so:

You may also have notice that there are some items checked. I highly recommend that you check the item related to "Don't display a warning if an alarm command is set." This is because by default, the Xfce4 Timer displays its own dialog box and we will need to use our own if we only want to see something like that on a particular day of the week.

If you are curious about the "Default command," the text within the input box is as follows:

        
        play /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga
    

...the result of which plays a classic wristwatch "beep" sound repeatedly if no specific "Command to run" is used and that particular audio file should be on most modern GNU/Linux systems.

Step 03: Making it all work...

Anyway, did you notice that the screenshot in the previous step already has an alarm added, labled as "Monday Evening" and is to occur at 17:30 (or 5:30 PM)?

The BASH script used in the "Command to run" is as follows:

        
        #!/bin/bash
        
        DAYS="Mon" #For multiple days, use DAYS="Mon\|Tue\|Wed"
        TITLE="Title of alarm"
        MESSAGE="Something important to do on Monday evenings"

        if [ "$(date | grep -o "$DAYS")" != '' ]
        then
            yad --title "$TITLE" --text "$MESSAGE" --geometry=320x200 --text-align=center &
            play /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga
        fi
    

The "IF-THEN" statement, combined with the 'date' and 'awk' commands, lets us confirm whether or not the day of the week is 'Mon' (Monday) and even though the Xfce4 Timer will run the alarm everyday at 17:30 (5:30 PM), it will only show the YAD-based dialog box and play the beep sound if the IF-THEN statement is true. The "&" part at the end of the 'yad' line is important so as to have both the dialog and audio at the same time. The "\n" part within YAD's "--text" is for creating new lines. A "one-liner" version of this script in the "Command to run" area will not work; I am not sure why.

Here is a screenshot of Editing the "Monday Evening" alarm:

Make sure to have "Recurring alarm" enabled if this alarm is to take place weekly and you should also enable the "Auto start when plugin loads"; otherwise, after logging in, you will have to left-click the Xfce4 Timer applet and select the alarm(s) to turn them on, which is very easy to forget to do, if not tedious.





Disclaimer