Hooks

subscribe.ghn_new_notification()

GithubNotifications widget.

Fired when there is a new notification.

Note: the hook will only be fired whenever the widget polls.

from libqtile import qtile
from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.ghn_new_notification
def ghn_notification():
    qtile.spawn("ffplay ding.wav")
subscribe.lfs_goal_scored()

LiveFootballScores widget.

Fired when the score in a match changes.

Hooked function should receive one argument which is the FootballMatch object for the relevant match.

Note: as the widget polls all matches at the same time, you may find that the hook is fired multiple times in quick succession. Handling multiple hooks is left to the user to manage.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.lfs_goal_scored
def goal(match):
    if "Arsenal" in (match.home_team, match.away_team):
      qtile.spawn("ffplay goal.wav")
subscribe.lfs_red_card()

LiveFootballScores widget.

Fired when a red card is issued in a match.

Hooked function should receive one argument which is the FootballMatch object for the relevant match.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.lfs_red_card
def red_card(match):
    if "Arsenal" in (match.home_team, match.away_team):
        qtile.spawn("ffplay off.wav")
subscribe.lfs_status_change()

LiveFootballScores widget.

Fired when the match status changes (i.e. kick-off, half time etc.).

Hooked function should receive one argument which is the FootballMatch object for the relevant match.

Note: as the widget polls all matches at the same time, you may find that the hook is fired multiple times in quick succession. Handling multiple hooks is left to the user to manage.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.lfs_status_change
def status(match):
    if match.is_finished and "Arsenal" in (match.home_team, match.away_team):
        qtile.spawn("ffplay whistle.wav")
subscribe.mpris_new_track()

Mpris2 widget.

Fired when a track changes. Receives a dict of the new metadata.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.mpris_new_track
def new_track(metadata):
    if metadata["xesam:title"] == "Never Gonna Give You Up":
        qtile.spawn("max_volume.sh")
subscribe.mpris_status_change()

Mpris2 widget.

Fired when the playback status changes. Receives a string containing the new status.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.mpris_status_change
def new_track(status):
    if status == "Stopped":
        qtile.spawn("mute.sh")
    else:
        qtile.spawn("unmute.sh")
subscribe.st_sync_started()

Syncthing widget.

Fired when a sync starts.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.st_sync_started
def sync_start():
    qtile.spawn("ffplay start.wav")
subscribe.st_sync_stopped()

Syncthing widget.

Fired when a sync stops.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.st_sync_stopped
def sync_stop():
    qtile.spawn("ffplay complete.wav")
subscribe.tvh_recording_ended()

TVHeadend widget.

Fired when a recording ends.

Hooked function should receive one argument which is the name of the program that was recorded.

from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.tvh_recording_ended
def stop_recording(prog):
    send_notification("Recording Ended", prog)
subscribe.tvh_recording_started()

TVHeadend widget.

Fired when a recording starts.

Hooked function should receive one argument which is the name of the program being recorded.

from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.tvh_recording_started
def start_recording(prog):
    send_notification("Recording Started", prog)
subscribe.up_battery_critical()

UPowerWidget.

Fired when a battery is critically low.

from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.up_battery_critical
def battery_critical(battery_name):
    send_notification(battery_name, "Battery is critically low. Plug in power supply.")
subscribe.up_battery_full()

UPowerWidget.

Fired when a battery is fully charged.

from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.up_battery_full
def battery_full(battery_name):
    send_notification(battery_name, "Battery is fully charged.")
subscribe.up_battery_low()

UPowerWidget.

Fired when a battery reaches low threshold.

from libqtile.utils import send_notification

import qtile_extras.hook

@qtile_extras.hook.subscribe.up_battery_low
def battery_low(battery_name):
    send_notification(battery_name, "Battery is running low.")
subscribe.up_power_connected()

UPowerWidget.

Fired when a power supply is connected.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.up_power_connected
def plugged_in():
    qtile.spawn("ffplay power_on.wav")
subscribe.up_power_disconnected()

UPowerWidget.

Fired when a power supply is disconnected.

from libqtile import qtile

import qtile_extras.hook

@qtile_extras.hook.subscribe.up_power_disconnected
def unplugged():
    qtile.spawn("ffplay power_off.wav")