Skip to content
enkore edited this page Jan 12, 2014 · 2 revisions
from i3pystatus import Status, Module

class ShutdownButton(Module):
    output = {
        "full_text": "\uF3A9",
    }
    def on_leftclick(self):
        import subprocess
        subprocess.Popen(["dmenu_runstate"])

status = Status(standalone=True)
# ...
status.register(ShutdownButton())

"\uF3A9" is a shutdown button with iconic fonts.

dmenu_runstate looks like this (for me):

#!/bin/zsh

# dmenu to change runstate using systemd

DMENU="dmenu -i -l 20 -fn 'Calibri-40'"
SYSTEMCTL="systemctl"

typeset -A CHOICES
CHOICES=(
    Shutdown    poweroff
    Reboot      reboot
    Hibernate   hibernate
    Suspend     suspend
    Halt        halt
)

CHOICE=$(print -l ${(k)CHOICES} | sort | ${=DMENU})

if [[ $? -eq 0 ]] then    
    ${=SYSTEMCTL} ${CHOICES[$CHOICE]}
fi
Clone this wiki locally