power menu

This commit is contained in:
mjallen18
2025-11-24 18:45:35 -06:00
parent 5aaae9ca99
commit e985d6e104
5 changed files with 240 additions and 50 deletions

View File

@@ -0,0 +1,95 @@
{
config,
lib,
namespace,
pkgs,
...
}:
let
cfg = config.${namespace}.programs.waybar;
waybar-notifications = pkgs.writeScriptBin "waybar-notifications" ''
#!/usr/bin/env python
import subprocess
import json
import codecs
import re
def check_notifications(args = "history"):
notifications = []
number = None
content = None
appname = None
urgency = None
cmd = "makoctl"
temp = subprocess.Popen([cmd, args], stdout = subprocess.PIPE)
output = str(temp.communicate()).replace("(b\'", "").replace("\', None)", "")
lines = output.split("\\n")
for line in lines:
if "Notification" in line:
number = line.split(":")[0].replace("Notification ", "")
content = re.sub(r"[\u2066\u2067\u2068\u2069, \u00e2\u0081\u00a8]", "", codecs.decode(line.split(": ")[-1].encode("latin1").decode("utf-8"), "unicode_escape"))
content = re.sub(r"[\u00a9]", " ", content)
if "App name" in line:
appname = line.split(": ")[-1]
if "Urgency" in line:
urgency = line.split(": ")[-1]
if number is not None and content is not None and appname is not None and urgency is not None:
notifications.append((number, content, appname, urgency))
number = None
content = None
appname = None
urgency = None
return notifications
def get_icon(notifications):
status = ""
icon = ""
for number, content, appname, urgency in notifications:
status = "notify"
if urgency != "normal":
status = "alert"
break
if status == "notify":
icon = "󰂞"
if status == "alert":
icon = "󰵙"
return icon, status
def build_tooltip(notifications):
tooltip = ""
for number, content, appname, urgency in notifications:
tooltip += "{0}: {1}\n".format(appname, content)
return tooltip
def main():
notifications = check_notifications()
data = {}
icon, status = get_icon(notifications)
data["text"] = icon
data["tooltip"] = build_tooltip(notifications)
data["class"] = status
print(json.dumps(data, ensure_ascii=False))
main()
'';
in
{
imports = [ ../options.nix ];
config = lib.mkIf cfg.enable {
home.packages = [ waybar-notifications ];
};
}

View File

@@ -189,100 +189,100 @@ let
' '],
"VeryCloudy": [
' ',
'<span foreground=\"#585858\"; font-weight: bold;"> .--. </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> .-( ). </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> (___.__)__) </span>',
'<span foreground=\"#585858\" font-weight="bold"> .--. </span>',
'<span foreground=\"#585858\" font-weight="bold"> .-( ). </span>',
'<span foreground=\"#585858\" font-weight="bold"> (___.__)__) </span>',
' '],
"LightShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#BBBBBB\">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#BBBBBB\">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#BBBBBB\">(___(__) </span>',
'<span foreground=\"#87afff\";"> </span>',
'<span foreground=\"#87afff\";"> </span>'],
'<span foreground=\"#87afff\"> </span>',
'<span foreground=\"#87afff\"> </span>'],
"HeavyShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#585858\"; font-weight: bold;">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#585858\"; font-weight: bold;">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#585858\"; font-weight: bold;">(___(__) </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>'],
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#585858\" font-weight="bold">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#585858\" font-weight="bold">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#585858\" font-weight="bold">(___(__) </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>'],
"LightSnowShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#BBBBBB\">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#BBBBBB\">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#BBBBBB\">(___(__) </span>',
'<span foreground=\"#eeeeee\";"> * * * </span>',
'<span foreground=\"#eeeeee\";"> * * * </span>'],
'<span foreground=\"#eeeeee\"> * * * </span>',
'<span foreground=\"#eeeeee\"> * * * </span>'],
"HeavySnowShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#585858\"; font-weight: bold;">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#585858\"; font-weight: bold;">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#585858\"; font-weight: bold;">(___(__) </span>',
'<span foreground=\"#eeeeee\"; font-weight: bold;"> * * * * </span>',
'<span foreground=\"#eeeeee\"; font-weight: bold;"> * * * * </span>'],
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#585858\" font-weight="bold">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#585858\" font-weight="bold">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#585858\" font-weight="bold">(___(__) </span>',
'<span foreground=\"#eeeeee\" font-weight="bold"> * * * * </span>',
'<span foreground=\"#eeeeee\" font-weight="bold"> * * * * </span>'],
"LightSleetShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#BBBBBB\">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#BBBBBB\">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#BBBBBB\">(___(__) </span>',
'<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">*</span>"<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">* </span>',
'<span foreground=\"#eeeeee\";"> *</span>"<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">*</span>"<span foreground=\"#87afff\";"> </span>'],
'<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">*</span>"<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">* </span>',
'<span foreground=\"#eeeeee\"> *</span>"<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">*</span>"<span foreground=\"#87afff\"> </span>'],
"ThunderyShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#BBBBBB\">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#BBBBBB\">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#BBBBBB\">(___(__) </span>',
'<span foreground=\"#ffff87\";"> \\</span>"<span foreground=\"#87afff\";"> </span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#87afff\";"> </span>',
'<span foreground=\"#87afff\";"> </span>'],
'<span foreground=\"#ffff87\"> \\</span>"<span foreground=\"#87afff\"> </span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#87afff\"> </span>',
'<span foreground=\"#87afff\"> </span>'],
"ThunderyHeavyRain": [
'<span foreground=\"#585858\"; font-weight: bold;"> .-. </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> ( ). </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> (___(__) </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#0000ff\";"></span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#0000ff\";"> </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#0000ff\";"> </span>'],
'<span foreground=\"#585858\" font-weight="bold"> .-. </span>',
'<span foreground=\"#585858\" font-weight="bold"> ( ). </span>',
'<span foreground=\"#585858\" font-weight="bold"> (___(__) </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#0000ff\"></span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#0000ff\"> </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#0000ff\"> </span>'],
"ThunderySnowShowers": [
'<span foreground=\"#FFFF00\"> _`/\'\'</span>"<span foreground=\"#BBBBBB\">.-. </span>',
'<span foreground=\"#FFFF00\"> ,\\_</span>"<span foreground=\"#BBBBBB\">( ). </span>',
'<span foreground=\"#FFFF00\"> /</span>"<span foreground=\"#BBBBBB\">(___(__) </span>',
'<span foreground=\"#eeeeee\";"> *</span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#eeeeee\";">*</span>"<span foreground=\"#ffff87\";">\\</span>"<span foreground=\"#eeeeee\";">* </span>',
'<span foreground=\"#eeeeee\";"> * * * </span>'],
'<span foreground=\"#eeeeee\"> *</span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#eeeeee\">*</span>"<span foreground=\"#ffff87\">\\</span>"<span foreground=\"#eeeeee\">* </span>',
'<span foreground=\"#eeeeee\"> * * * </span>'],
"LightRain": [
'<span foreground=\"#BBBBBB\"> .-. </span>',
'<span foreground=\"#BBBBBB\"> ( ). </span>',
'<span foreground=\"#BBBBBB\"> (___(__) </span>',
'<span foreground=\"#87afff\";"> </span>',
'<span foreground=\"#87afff\";"> </span>'],
'<span foreground=\"#87afff\"> </span>',
'<span foreground=\"#87afff\"> </span>'],
"HeavyRain": [
'<span foreground=\"#585858\"; font-weight: bold;"> .-. </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> ( ). </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> (___(__) </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>',
'<span foreground=\"#0000ff\"; font-weight: bold;"> </span>'],
'<span foreground=\"#585858\" font-weight="bold"> .-. </span>',
'<span foreground=\"#585858\" font-weight="bold"> ( ). </span>',
'<span foreground=\"#585858\" font-weight="bold"> (___(__) </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>',
'<span foreground=\"#0000ff\" font-weight="bold"> </span>'],
"LightSnow": [
'<span foreground=\"#BBBBBB\"> .-. </span>',
'<span foreground=\"#BBBBBB\"> ( ). </span>',
'<span foreground=\"#BBBBBB\"> (___(__) </span>',
'<span foreground=\"#eeeeee\";"> * * * </span>',
'<span foreground=\"#eeeeee\";"> * * * </span>'],
'<span foreground=\"#eeeeee\"> * * * </span>',
'<span foreground=\"#eeeeee\"> * * * </span>'],
"HeavySnow": [
'<span foreground=\"#585858\"; font-weight: bold;"> .-. </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> ( ). </span>',
'<span foreground=\"#585858\"; font-weight: bold;"> (___(__) </span>',
'<span foreground=\"#eeeeee\"; font-weight: bold;"> * * * * </span>',
'<span foreground=\"#eeeeee\"; font-weight: bold;"> * * * * </span>'],
'<span foreground=\"#585858\" font-weight="bold"> .-. </span>',
'<span foreground=\"#585858\" font-weight="bold"> ( ). </span>',
'<span foreground=\"#585858\" font-weight="bold"> (___(__) </span>',
'<span foreground=\"#eeeeee\" font-weight="bold"> * * * * </span>',
'<span foreground=\"#eeeeee\" font-weight="bold"> * * * * </span>'],
"LightSleet": [
'<span foreground=\"#BBBBBB\"> .-. </span>',
'<span foreground=\"#BBBBBB\"> ( ). </span>',
'<span foreground=\"#BBBBBB\"> (___(__) </span>',
'<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">*</span>"<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">* </span>',
'<span foreground=\"#eeeeee\";"> *</span>"<span foreground=\"#87afff\";"> </span>"<span foreground=\"#eeeeee\";">*</span>"<span foreground=\"#87afff\";"> </span>'],
'<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">*</span>"<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">* </span>',
'<span foreground=\"#eeeeee\"> *</span>"<span foreground=\"#87afff\"> </span>"<span foreground=\"#eeeeee\">*</span>"<span foreground=\"#87afff\"> </span>'],
"Fog": [
' ',
'<span foreground=\"#c0c0c0\";"> _ - _ - _ - </span>',
'<span foreground=\"#c0c0c0\";"> _ - _ - _ </span>',
'<span foreground=\"#c0c0c0\";"> _ - _ - _ - </span>',
'<span foreground=\"#c0c0c0\"> _ - _ - _ - </span>',
'<span foreground=\"#c0c0c0\"> _ - _ - _ </span>',
'<span foreground=\"#c0c0c0\"> _ - _ - _ - </span>',
' '],
}
WEATHER_CODES_WEGO = {key: WEATHER_SYMBOL_WEGO[value] for key, value in WWO_CODE.items()}
data = {}
data["text"] = ""
def format_time(time):
"""get the time formatted"""