Plugin: clock.sh
This is a very simple plugin that gets the current date and time and updates an item's label.
Usage
This script is designed to be run on a timer using the update_freq
property.
sketchybar --add item clock right \
--set clock update_freq=10 \
icon= \
script="$PLUGIN_DIR/clock.sh"
update_freq=10
: Runs the script every 10 seconds to keep the time reasonably current without excessive updates.
Source Code
#!/bin/sh
# The $NAME variable is passed from sketchybar and holds the name of
# the item invoking this script:
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
sketchybar --set "$NAME" label="$(date '+%d/%m %H:%M')"
Explanation
date '+%d/%m %H:%M'
: The standarddate
command is used to format the current date and time. The format string+%d/%m %H:%M
produces output like23/10 14:30
.sketchybar --set "$NAME" label="..."
: This command updates thelabel
property of the item that ran the script (identified by the$NAME
environment variable) with the formatted date string.