How to change clock settings

Created by Peter Levi
Keywords:
clock
Last updated by:
Peter Levi

THE clock_filter SETTING

Clock's appearance and placement are determined by the <code>clock_filter</code> setting in Variety's config file <code>~/.config/variety/variety.conf</code>. There are comments there to guide you. If you don't see any comments there, please find them in <code>~/.config/variety/variety_latest_default.conf</code> (but make changes in variety.conf, not here - this file is there just for your reference).

The clock filter is quite hairy, but don't get scared, you don't need to edit everything. Here it is, as of version 0.4.12:

<code>clock_filter = "-density 100 -font `fc-match -f '%{file[0]}' '%CLOCK_FONT_NAME'` -pointsize %CLOCK_FONT_SIZE -gravity SouthEast -fill '#00000044' -annotate 0x0+[%HOFFSET+58]+[%VOFFSET+108] '%H:%M' -fill white -annotate 0x0+[%HOFFSET+60]+[%VOFFSET+110] '%H:%M' -font `fc-match -f '%{file[0]}' '%DATE_FONT_NAME'` -pointsize %DATE_FONT_SIZE -fill '#00000044' -annotate 0x0+[%HOFFSET+58]+[%VOFFSET+58] '%A, %B %d' -fill white -annotate 0x0+[%HOFFSET+60]+[%VOFFSET+60] '%A, %B %d'"
</code>

Both the clock and date texts are present two times, because they are written twice in different colors to get a slight shadow effect.

FONTS

On a recent installation (after version 0.4.12), you will see several <code>%FONT</code> variables - these are replaced with the fonts and sizes for the clock and the date, as configured in Variety's preferences GUI. If these variables are not present and specific font names and sizes are used instead, then the font settings in the GUI won't work.

CLOCK AND DATE FORMAT

The variables %H, %M, etc. in the clock filter are replaced with portions from the current date and time (localized for your computer's locale setting). The full list of variables you can use there can be seen here: http://docs.python.org/library/datetime.html#strftime-strptime-behavior

The most common request is to have 12-hour format clock:

You need to replace %H:%M with %I:%M %p in clock_filter - %I is for hours (12), %p - for the locale-specific string for AM or PM.

PLACEMENT

Clock placement is determined by the gravity parameters - <code>SouthEast</code> means the lower right corner.

A FULL-BLOWN IMAGEMAGICK COMMAND

After all the variables are filled in, the line is sent to ImageMagick, so you may be really creative here, use as this guide to get ideas and as a reference: http://www.imagemagick.org/Usage/
You can get a very uniquely looking clock with some of the more advanced techniques (e.g. circle-shaped text, interesting colors and shading, etc....).

Here are the comments from variety.conf, if you don't find them:

# clock_filter = <an ImageMagick filter, read below>
#
# The filter defines the ImageMagick command that Variety uses to render the clock on the wallpaper.
# First some scaling is applied to get the image down to the screen size - this ensures
# the final drawn clock won't be rescaled by the desktop wallpaper system.
# Easiest way to see what's happening is to run variety with -v, enable clock and see what ImageMagick
# commands Variety dumps in the log.
#
# The user may want to customize the following aspects:
# fill - color of "filling"
# stroke - color of outline
# strokewidth - width of outline
# gravity - in which corner to display the clock - SouthEast, NorthEast, SouthWest, NorthWest
# annotate - these must be in the form 0x0+[%HOFFSET+X]+[%VOFFSET+Y], where you can edit X and Y - distance from the screen corner defined by gravity. Write them in even if they are 0.
#
# The %HOFFSET and %VOFFSET parameters are there for Variety to replace in order to compensate for the diferent dimensions of every image and screen
# The several %FONT parameters are there for Variety to replace with the font settings from the GUI.
#
# The texts can contain these symbols:
#
# %H - hours (24), %I - hours (12), %p - am or pm, %M - minutes,
# %A - day of week (full), %a - day of week abbreviation, %B - month name, %b - month abbreviation, %d - day of month, %Y - year.
# The full list for these can be seen here: http://docs.python.org/library/datetime.html#strftime-strptime-behavior
# Have in mind that Variety will not update the clock more often than once every minute, so using seconds (%S) for example is pointless
#
# A tutorial on "annotating" with ImageMagick that you may use as a reference: http://www.imagemagick.org/Usage/annotating/
# You can get a very uniquely looking clock with some of the more advanced techniques (e.g. circle-shaped text, interesting colors and shading, etc....).