Integrating with taskbars¶
The following sections should give you some idea of how you can (ab)use the
<database>/.current
file in your window manager of choice.
Note
You’ll find exactly two examples right now, because these are the only two environments I use. Feel free to submit your own!
Todo
Add more fleshed out examples.
awesomewm
¶
For example, with awesomewm, you could create a simple timer based widget that shows the running task:
GLib = lgi.GLib
tasktext = wibox.widget.textbox!
tasktimer = with gears.timer timeout: 30
\connect_signal "timeout", ->
if file = io.open GLib.get_user_data_dir! .. "/rdial/.current"
tasktext\set_markup file\read!
file\close!
else
tasktext\set_markup "none"
-- fire timer for initial update
\emit_signal "timeout"
\start!
Note
The above example is compact but very naïve, and will be incorrect in the time between state changes and updates. If you’re implementing your own widget you’ll be better served by using GFileMonitor to track state changes.
You could also hook the mouse::enter
and mouse::leave
signals to create
a naughty popup showing the task time, or use awful.button to allow you to
switch tasks directly from the taskbar.
dwm
¶
With dwm you’re basically free to pump the status bar however you wish. If
you’re one of the users who likes to use a shell script to configure the bar,
then you can just cat the .current
file from within your
script.
You could also edge towards mimicking the awesomewm configuration above with the following genie snippet leveraging glib:
[indent=4]
uses
X
Posix
init
var file = GLib.Environment.get_user_data_dir() + "/rdial/.current"
var dpy = new X.Display()
var root = dpy.default_root_window()
text : string
while true
if GLib.FileUtils.test(file, GLib.FileTest.IS_REGULAR)
GLib.FileUtils.get_contents(file, out text)
else
text = "none"
dpy->change_property(root, XA_WM_NAME, XA_STRING, 8,
PropMode.Replace, (array of uchar)text,
text.length)
dpy->flush()
Posix.sleep(30)
Note
The above example is compact but very naïve, and will be incorrect in the time between state changes and updates. If you’re implementing your own status tool you’ll be better served by using GFileMonitor to track state changes.
You could also implement a simple task manager using dmenu or rofi to bind to a key, the following zsh snippet shows how to build a selector for an existing task:
tasks=(${XDG_DATA_HOME:-~/.local/share}/rdial/*~*~(:t:s/.csv/))
rofi -dmenu -p "task?" <<< ${(F)tasks}