Initial commit

This commit is contained in:
2025-11-28 16:44:06 -08:00
commit c673a0bda5
27 changed files with 1563 additions and 0 deletions

133
waybar/config.jsonc Normal file
View File

@ -0,0 +1,133 @@
// -*- mode: jsonc -*-
{
"layer": "top",
"height": 34,
"spacing": 5,
"modules-left": ["river/tags"],
"modules-center": ["river/window"],
"modules-right": ["group/info-widgets", "group/tray"],
"river/tags": {
"num-tags": 9
},
"river/window": {
"tooltip": true,
"default-format": "river"
},
"group/info-widgets": {
"orientation": "inherit",
"modules": [
"custom/swayidle",
"river/mode",
"custom/mail",
"custom/ime",
"custom/battery",
"pulseaudio",
"clock#date",
"custom/time",
"custom/network",
"bluetooth"
]
},
"custom/swayidle": {
"exec": "pgrep swayidle >/dev/null 2>&1 || printf '󱙱 '",
"interval": 10,
"signal": 3,
"tooltip": false,
"hide-empty-text": true
},
"river/mode": {
"format": "󰩷 {}",
"hidden-modes": ["normal"]
},
"custom/mail": {
"format": " {}",
"exec": "~/scripts/eww/eww-mu4e-messages -g",
"interval": 15,
"signal": 2,
"tooltip": false,
"hide-empty-text": true
},
"custom/ime": {
"exec": "~/.config/river/waybar/fcitx5-state.el",
"interval": 15,
"signal": 1,
"tooltip": false,
"on-click": "~/scripts/eww/eww-fcitx5-toggle"
},
"custom/battery": {
"exec": "~/scripts/eww/eww-battery-monitor",
"return-type": "json",
"tooltip": true
},
"pulseaudio": {
"states": {
"zero": 0,
"low": 49,
"high": 100
},
"format-zero": "󰕿{volume:3}%",
"format-low": "󰖀{volume:3}%",
"format-high": "󰕾{volume:3}%",
"format-muted": "󰸈{volume:3}%",
"scroll-step": 5.0,
"on-click": "pamixer -t"
},
"clock#date": {
"on-click": "systemd-run --user --ignore-failure -- kitty -1 ikhal",
"format": " {:%a %b %d}",
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode": "month",
"mode-mon-col": 3,
"weeks-pos": "right",
"on-scroll": 1,
"format": {
"months": "<span color='#ffead3'><b>{}</b></span>",
"days": "<span color='#ecc6d9'><b>{}</b></span>",
"weeks": "<span color='#99ffdd'><b>W{}</b></span>",
"weekdays": "<span color='#ffcc66'><b>{}</b></span>",
"today": "<span color='#ff6699'><b><u>{}</u></b></span>"
}
},
"actions": {
"on-click-right": "mode",
"on-scroll-up": "shift_up",
"on-scroll-down": "shift_down"
}
},
"custom/time": {
"exec": "~/.config/river/waybar/waybar-clock.py CA America/Los_Angeles JP Asia/Tokyo",
"return-type": "json"
},
"custom/network": {
"exec": "~/.config/river/waybar/waybar-network.el",
"tooltip": false,
"on-click": "systemd-run --user --ignore-failure -- kitty -1 nmtui"
},
"bluetooth": {
"on-click": "systemd-run --user --ignore-failure -- blueman-manager",
"format": " ",
"format-off": ""
},
"group/tray": {
"orientation": "inherit",
"modules": ["custom/empty", "tray"],
"drawer": {
"toggle-signal": 4,
"transition-duration": 0
}
},
"custom/empty": {
"exec": "true",
"format": ""
},
"tray": {
"icon-size": 24,
"spacing": 5
}
}

26
waybar/fcitx5-state.el Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env -S emacs -x
;; -*- lexical-binding: t -*-
(require 'cl-lib)
(require 'server)
(require 'dbus)
(cl-defun server-input-method-name (&optional (server "server"))
(server-eval-at server 'current-input-method))
(cl-defun mozc-enabled-p (&optional (server "server"))
(equal (server-input-method-name server) "japanese-mozc"))
(defun fcitx5-enabled-p ()
(equal (dbus-call-method :session "org.fcitx.Fcitx5" "/controller"
"org.fcitx.Fcitx.Controller1" "State")
2))
(princ (if (or (mozc-enabled-p) (fcitx5-enabled-p))
""
""))
(terpri)
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:

68
waybar/style.css Normal file
View File

@ -0,0 +1,68 @@
* {
font-family: FiraCode Nerd Font;
font-size: 16px;
}
window#waybar {
background-color: #333333;
color: #ffffff;
}
#tags button {
border: none;
border-radius: 0;
min-width: 34px;
padding: 0;
margin: 0 0 0 5px;
text-shadow: none;
box-shadow: none;
transition-duration: 0;
}
#tags button:first-child {
margin: 0 0 0 0;
}
#tags button:hover {
background: lighter(#333333);
}
#tags button.focused {
background: red;
}
#tags button.urgent {
background: white;
color: red;
}
#tags button.occupied {
box-shadow: 0 2px white inset;
}
#tags button.current-view {
box-shadow: 0 4px white inset;
}
#window {
margin: 0 5px 0 5px;
font-family:
IPAPGothic,
FiraCode Nerd Font;
}
#info-widgets label:not(#bluetooth) {
margin-left: 20px;
}
#info-widgets > *:first-child label {
margin-left: 0;
}
#bluetooth {
margin-left: 5px;
}
#bluetooth.off {
margin-left: 0;
}

40
waybar/waybar-clock.py Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env python
from datetime import datetime
from zoneinfo import ZoneInfo
from itertools import batched
import json
import time
import sys
def format_output(zones):
# primary timezone
primary = datetime.now(zones[0][1]).strftime("%R")
tooltip = None
for label, zone in zones:
if not tooltip:
tooltip = "<tt>"
else:
tooltip += "\n"
tooltip += f"{label}: {datetime.now(zone).strftime('%R %a %b %d %Z')}"
tooltip += "</tt>"
json.dump({"text": primary, "tooltip": tooltip}, sys.stdout)
print(flush=True)
def main():
if len(sys.argv) == 1 or len(sys.argv) % 2 == 0:
print("usage: waybar-clock.py [<label> <zone>]...")
sys.exit(1)
zones = [
(label, ZoneInfo(zone_name))
for label, zone_name in batched(sys.argv[1:], 2)
]
while True:
format_output(zones)
time.sleep(0.5)
main()

78
waybar/waybar-network.el Executable file
View File

@ -0,0 +1,78 @@
#!/usr/bin/env -S emacs -x
;; -*- lexical-binding: t; -*-
(require 'cl-lib)
(require 'dbus)
(defconst connection-type-symbol-map
'((:none . "󰈂 ") ;; no connection
(:vpn . "󰖂 ")
(:wifi . "󰖩 ")
(:wired . "󰈁 "))
"Association list mapping connection types to their icons.")
(defun connection-type (path)
"Get the connection type for the active connection at PATH."
;; if the path is stale, just ignore it
(ignore-error dbus-error
(let ((type-string
(dbus-get-property :system
"org.freedesktop.NetworkManager"
path
"org.freedesktop.NetworkManager.Connection.Active"
"Type")))
(cond
((equal type-string "wireguard") :vpn)
((string-suffix-p "wireless" type-string) :wifi)
((string-suffix-p "ethernet" type-string) :wired)))))
(defun print-status-for-connection-types (conn-types)
"Write a status message for the connections in CONN-TYPES."
(princ (if (null conn-types)
(alist-get :none connection-type-symbol-map)
(mapconcat #'(lambda (type)
(alist-get type connection-type-symbol-map))
conn-types)))
(terpri)
(flush-standard-output))
(defun process-connection-list (connections)
"Process a list of paths to active connections."
(print-status-for-connection-types
(cl-loop for path in connections
for type = (connection-type path)
when type collect type)))
(defun list-active-connections ()
"Return a list of paths to active NetworkManager connections."
(dbus-get-property :system
"org.freedesktop.NetworkManager"
"/org/freedesktop/NetworkManager"
"org.freedesktop.NetworkManager"
"ActiveConnections"))
(defun handler (_interface-name changed-properties _invalidated-properties)
"Handler for property changes on NetworkManager."
(dolist (property changed-properties)
(when (equal (car property) "ActiveConnections")
;; the actual passed value may be stale
(process-connection-list (list-active-connections)))))
(dbus-register-signal :system
"org.freedesktop.NetworkManager" ;; service
"/org/freedesktop/NetworkManager" ;; path
"org.freedesktop.DBus.Properties" ;; interface
"PropertiesChanged" ;; signal
#'handler)
;; print initial connection list
(process-connection-list (list-active-connections))
(while t
(let ((event (read-event)))
(when (ignore-error dbus-error (dbus-check-event event))
(dbus-handle-event event))))
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End: