Add twmn module for switching notifications on and off

This commit is contained in:
Milos Miljanic 2019-07-30 19:48:08 +02:00
parent 44bc1ab287
commit 1853723eb1
No known key found for this signature in database
GPG key ID: 34AC6A0400650287
4 changed files with 702 additions and 481 deletions

39
bumblebee/modules/twmn.py Normal file
View file

@ -0,0 +1,39 @@
#pylint: disable=C0111,R0903
"""Toggle twmn notifications."""
import bumblebee.input
import bumblebee.output
import bumblebee.engine
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text="")
)
self._paused = False
# Make sure that twmn is currently not paused
try:
bumblebee.util.execute("killall -SIGUSR2 twmnd")
except:
pass
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self.toggle_status
)
def toggle_status(self, event):
self._paused = not self._paused
try:
if self._paused:
bumblebee.util.execute("systemctl --user start twmnd")
else:
bumblebee.util.execute("systemctl --user stop twmnd")
except:
self._paused = not self._paused # toggling failed
def state(self, widget):
if self._paused:
return ["muted"]
return ["unmuted"]

View file

@ -2,85 +2,204 @@
"defaults": {
"padding": " "
},
"memory": { "prefix": "ram" },
"cpu": { "prefix": "cpu" },
"disk": { "prefix": "hdd" },
"dnf": { "prefix": "dnf" },
"apt": { "prefix": "apt" },
"brightness": { "prefix": "o" },
"memory": {
"prefix": "ram"
},
"cpu": {
"prefix": "cpu"
},
"disk": {
"prefix": "hdd"
},
"dnf": {
"prefix": "dnf"
},
"apt": {
"prefix": "apt"
},
"brightness": {
"prefix": "o"
},
"cmus": {
"playing": { "prefix": ">" },
"paused": { "prefix": "||" },
"stopped": { "prefix": "[]" },
"prev": { "prefix": "|<" },
"next": { "prefix": ">|" },
"shuffle-on": { "prefix": "S" },
"shuffle-off": { "prefix": "[s]" },
"repeat-on": { "prefix": "R" },
"repeat-off": { "prefix": "[r]" }
"playing": {
"prefix": ">"
},
"paused": {
"prefix": "||"
},
"stopped": {
"prefix": "[]"
},
"prev": {
"prefix": "|<"
},
"next": {
"prefix": ">|"
},
"shuffle-on": {
"prefix": "S"
},
"shuffle-off": {
"prefix": "[s]"
},
"repeat-on": {
"prefix": "R"
},
"repeat-off": {
"prefix": "[r]"
}
},
"pasink": {
"muted": { "prefix": "audio(mute)" },
"unmuted": { "prefix": "audio" }
"muted": {
"prefix": "audio(mute)"
},
"unmuted": {
"prefix": "audio"
}
},
"amixer": {
"muted": { "prefix": "audio(mute)" },
"unmuted": { "prefix": "audio" }
"muted": {
"prefix": "audio(mute)"
},
"unmuted": {
"prefix": "audio"
}
},
"pasource": {
"muted": { "prefix": "mic(mute)" },
"unmuted": { "prefix": "mic" }
"muted": {
"prefix": "mic(mute)"
},
"unmuted": {
"prefix": "mic"
}
},
"nic": {
"wireless-up": { "prefix": "wifi" },
"wireless-down": { "prefix": "wifi" },
"wired-up": { "prefix": "lan" },
"wired-down": { "prefix": "lan" },
"tunnel-up": { "prefix": "tun" },
"tunnel-down": { "prefix": "tun" }
"wireless-up": {
"prefix": "wifi"
},
"wireless-down": {
"prefix": "wifi"
},
"wired-up": {
"prefix": "lan"
},
"wired-down": {
"prefix": "lan"
},
"tunnel-up": {
"prefix": "tun"
},
"tunnel-down": {
"prefix": "tun"
}
},
"battery": {
"charged": { "suffix": "full" },
"charging": { "suffix": "chr" },
"AC": { "suffix": "ac" },
"charged": {
"suffix": "full"
},
"charging": {
"suffix": "chr"
},
"AC": {
"suffix": "ac"
},
"discharging-10": {
"prefix": "!",
"suffix": "dis"
},
"discharging-25": { "suffix": "dis" },
"discharging-50": { "suffix": "dis" },
"discharging-80": { "suffix": "dis" },
"discharging-100": { "suffix": "dis" },
"unknown-25": { "suffix": "?" },
"unknown-50": { "suffix": "?" },
"unknown-80": { "suffix": "?" },
"unknown-100": { "suffix": "?" }
"discharging-25": {
"suffix": "dis"
},
"discharging-50": {
"suffix": "dis"
},
"discharging-80": {
"suffix": "dis"
},
"discharging-100": {
"suffix": "dis"
},
"unknown-25": {
"suffix": "?"
},
"unknown-50": {
"suffix": "?"
},
"unknown-80": {
"suffix": "?"
},
"unknown-100": {
"suffix": "?"
}
},
"battery_all": {
"charged": { "suffix": "full" },
"charging": { "suffix": "chr" },
"AC": { "suffix": "ac" },
"charged": {
"suffix": "full"
},
"charging": {
"suffix": "chr"
},
"AC": {
"suffix": "ac"
},
"discharging-10": {
"prefix": "!",
"suffix": "dis"
},
"discharging-25": { "suffix": "dis" },
"discharging-50": { "suffix": "dis" },
"discharging-80": { "suffix": "dis" },
"discharging-100": { "suffix": "dis" },
"unknown-25": { "suffix": "?" },
"unknown-50": { "suffix": "?" },
"unknown-80": { "suffix": "?" },
"unknown-100": { "suffix": "?" }
"discharging-25": {
"suffix": "dis"
},
"discharging-50": {
"suffix": "dis"
},
"discharging-80": {
"suffix": "dis"
},
"discharging-100": {
"suffix": "dis"
},
"unknown-25": {
"suffix": "?"
},
"unknown-50": {
"suffix": "?"
},
"unknown-80": {
"suffix": "?"
},
"unknown-100": {
"suffix": "?"
}
},
"caffeine": {
"activated": {"prefix": "caf-on" }, "deactivated": { "prefix": "caf-off " }
"activated": {
"prefix": "caf-on"
},
"deactivated": {
"prefix": "caf-off "
}
},
"xrandr": {
"on": { "prefix": " off "}, "off": { "prefix": " on "}, "refresh": { "prefix": " refresh "}
"on": {
"prefix": " off "
},
"off": {
"prefix": " on "
},
"refresh": {
"prefix": " refresh "
}
},
"redshift": {
"day": { "prefix": "day" }, "night": { "prefix": "night" }, "transition": { "prefix": "trans" }
"day": {
"prefix": "day"
},
"night": {
"prefix": "night"
},
"transition": {
"prefix": "trans"
}
},
"docker_ps": {
"prefix": "containers"
@ -89,23 +208,41 @@
"prefix": "sensors"
},
"traffic": {
"rx": { "prefix": "down"},
"tx": { "prefix": "up"}
"rx": {
"prefix": "down"
},
"network_traffic": {
"rx": { "prefix": "down" },
"tx": { "prefix": "up" }
"tx": {
"prefix": "up"
}
},
"mpd": {
"playing": { "prefix": ">" },
"paused": { "prefix": "||" },
"stopped": { "prefix": "[]" },
"prev": { "prefix": "|<" },
"next": { "prefix": ">|" },
"shuffle-on": { "prefix": "S" },
"shuffle-off": { "prefix": "[s]" },
"repeat-on": { "prefix": "R" },
"repeat-off": { "prefix": "[r]" }
"playing": {
"prefix": ">"
},
"paused": {
"prefix": "||"
},
"stopped": {
"prefix": "[]"
},
"prev": {
"prefix": "|<"
},
"next": {
"prefix": ">|"
},
"shuffle-on": {
"prefix": "S"
},
"shuffle-off": {
"prefix": "[s]"
},
"repeat-on": {
"prefix": "R"
},
"repeat-off": {
"prefix": "[r]"
}
},
"github": {
"prefix": "github"
@ -117,21 +254,50 @@
"prefix": "uptime"
},
"zpool": {
"poolread": {"prefix": "pool read "},
"poolwrite": {"prefix": "pool write "},
"ONLINE": {"prefix": "pool"},
"FAULTED": {"prefix": "pool (!)"},
"DEGRADED": {"prefix": "pool (!)"}
"poolread": {
"prefix": "pool read "
},
"poolwrite": {
"prefix": "pool write "
},
"ONLINE": {
"prefix": "pool"
},
"FAULTED": {
"prefix": "pool (!)"
},
"DEGRADED": {
"prefix": "pool (!)"
}
},
"git": {
"main": { "prefix": "" },
"new": { "prefix": "[n]" },
"modified": { "prefix": "[m]" },
"deleted": { "prefix": "[d]" }
"main": {
"prefix": ""
},
"new": {
"prefix": "[n]"
},
"modified": {
"prefix": "[m]"
},
"deleted": {
"prefix": "[d]"
}
},
"dunst": {
"muted": { "prefix": "dunst(muted)"},
"unmuted": { "prefix": "dunst" }
"muted": {
"prefix": "dunst(muted)"
},
"unmuted": {
"prefix": "dunst"
}
},
"twmn": {
"muted": {
"prefix": "twmn"
},
"unmuted": {
"prefix": "twmn(muted)"
}
}
}

View file

@ -1,6 +1,7 @@
{
"defaults": {
"separator": "", "padding": " ",
"separator": "",
"padding": " ",
"unknown": { "prefix": "" }
},
"date": { "prefix": "" },
@ -19,10 +20,12 @@
"load": { "prefix": "" },
"layout": { "prefix": "" },
"layout-xkb": { "prefix": "" },
"notmuch_count": { "empty": {"prefix": "\uf0e0" },
"notmuch_count": {
"empty": { "prefix": "\uf0e0" },
"items": { "prefix": "\uf0e0" }
},
"todo": { "empty": {"prefix": "" },
"todo": {
"empty": { "prefix": "" },
"items": { "prefix": "" },
"uptime": { "prefix": "" }
},
@ -200,6 +203,10 @@
"muted": { "prefix": "" },
"unmuted": { "prefix": "" }
},
"twmn": {
"muted": { "prefix": "" },
"unmuted": { "prefix": "" }
},
"pihole": {
"enabled": { "prefix": "" },
"disabled": { "prefix": "" }

View file

@ -1,6 +1,7 @@
{
"defaults": {
"separator": "\ue0b2", "padding": "\u2800",
"separator": "\ue0b2",
"padding": "\u2800",
"unknown": { "prefix": "\uf100" }
},
"date": { "prefix": "\uf2d1" },
@ -16,7 +17,8 @@
"load": { "prefix": "\uf13d" },
"layout": { "prefix": "\uf38c" },
"layout-xkb": { "prefix": "\uf38c" },
"todo": { "empty": {"prefix": "\uf453" },
"todo": {
"empty": { "prefix": "\uf453" },
"items": { "prefix": "\uf454" },
"uptime": { "prefix": "\uf4c1" }
},
@ -114,13 +116,17 @@
"estimate": { "prefix": "\uf402" }
},
"caffeine": {
"activated": {"prefix": "\uf272\u3000\uf354" }, "deactivated": { "prefix": "\uf272\u3000\uf355" }
"activated": { "prefix": "\uf272\u3000\uf354" },
"deactivated": { "prefix": "\uf272\u3000\uf355" }
},
"xrandr": {
"on": { "prefix": "\uf465\u3000\uf354"}, "off": { "prefix": "\uf465\u3000\uf355" }
"on": { "prefix": "\uf465\u3000\uf354" },
"off": { "prefix": "\uf465\u3000\uf355" }
},
"redshift": {
"day": { "prefix": "\uf4b6" }, "night": { "prefix": "\uf467" }, "transition": { "prefix": "\uf475" }
"day": { "prefix": "\uf4b6" },
"night": { "prefix": "\uf467" },
"transition": { "prefix": "\uf475" }
},
"sensors": {
"prefix": "\uf3b6"
@ -166,6 +172,9 @@
"dunst": {
"muted": { "prefix": "\uf39a" },
"unmuted": { "prefix": "\uf39b" }
},
"twmn": {
"muted": { "prefix": "\uf1f6" },
"unmuted": { "prefix": "\uf0f3" }
}
}