diff options
| author | Nick Moore <nicholasvmoore@gmail.com> | 2026-11-07 07:53:41 -0600 |
|---|---|---|
| committer | Nick Moore <nicholasvmoore@gmail.com> | 2026-11-07 07:53:41 -0600 |
| commit | f0bcbef5a603c16ee5639aac7dc79e7714b2d27f (patch) | |
| tree | f897d73edcac85069cb14d4cc82630f22ec24c92 | |
| parent | fdd75214837275a1fe37ba991e45bd1ae4fa5814 (diff) | |
Add AGENTS.md context files, prune backup/state, restage waybar for stow
- AGENTS.md at repo root + waybar/AGENTS.md component layer
- untrack *.bak and fish_variables (machine-local session state)
- waybar restructured to .config/waybar/ and synced from rigel (laptop wins): sway modules, doom-one style, ppd-glyph.py + wifi-icon.py
| -rw-r--r-- | .gitignore | 10 | ||||
| -rw-r--r-- | AGENTS.md | 77 | ||||
| -rw-r--r-- | alacritty/.config/alacritty/alacritty.toml.bak | 34 | ||||
| -rw-r--r-- | fish/.config/fish/fish_variables | 104 | ||||
| -rw-r--r-- | waybar/.config/waybar/config.jsonc | 109 | ||||
| -rwxr-xr-x | waybar/.config/waybar/ppd-glyph.py | 92 | ||||
| -rw-r--r-- | waybar/.config/waybar/style.css | 182 | ||||
| -rwxr-xr-x | waybar/.config/waybar/wifi-icon.py | 157 | ||||
| -rw-r--r-- | waybar/config | 35 | ||||
| -rw-r--r-- | waybar/modules.json.bak | 207 | ||||
| -rw-r--r-- | waybar/modules.jsonc | 84 | ||||
| -rw-r--r-- | waybar/style.css | 117 | ||||
| -rw-r--r-- | waybar/style.css.bak | 357 |
13 files changed, 627 insertions, 938 deletions
@@ -2,6 +2,16 @@ **/.github/ **/.gitattributes +# local state: machine-regenerated, never portable, never secret-free +**/fish_variables + +# backup files created while editing live configs +**/*.bak +**/*.bak.* + +# python bytecode +**/__pycache__/ + # tmux plugins # I want to keep the tmux-battery because of an issue with # my uConsole battery when a bluetooth device is connected. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..9d13b13 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,77 @@ +# dotfiles — Agent Context + +Personal configuration repository, deployed as GNU stow packages, public +at `git.pcola.moorenix.com:git-public/dotfiles.git`. + +Each top-level directory (except shared docs like this file) is a stow +**package** that mirrors `$HOME` exactly, e.g. `waybar/.config/waybar/`. +More specific agent context lives one level down — read this file first, +then the `AGENTS.md` inside the package you're working on (if it has +one); machine layers describe per-machine hardware/role facts. + +## Deploy model + +- Deploy on a machine with GNU stow from the repo root: + `stow --adopt -t ~ <pkg> ...` — `--adopt` pulls an existing target file + into the package and symlinks it, converting a live config into + stow-managed without a copy/symlink dance. Dry-run first with `-n -v2`. +- Not every package applies to every machine. `sway/`, `foot/`, etc. are + flagship packages; `hypr/`, `fish/`, `rofi/`, `alacritty/` belong to + other machines/stacks and are loaded only there. + +## Layout invariants + +- Always `.config/<tool>/...` nesting — no flat exceptions. +- One package per tool/theme unit; don't nest unrelated tools inside a + package just because they install together. +- Machine-specific content (display config, input quirks, machine roles, + machine-hosted scripts like ppd-switch) lives inside a package's + per-machine section — see `sway/AGENTS.md` once sway/ is tracked — + never in shared configs and never by hardcoding into a shared file. + +## Styling invariant + +doom-one palette + Terminess Nerd Font are the system-wide look. Every +machine, every tool, same palette: + + bg #282c34 fg #bbc2cf blue #51afef magenta #c678dd + red #ff6c6b green #98be65 yellow #ecbe7b cyan #46d9ff + orange #da8548 violet #a9a1e1 base3 #3f444a base5 #5b6268 + +If a tool's config already carries these values, reuse rather than +restate; if it needs *additional* theming, derive from this palette. +Never fork the palette per machine — consistent feel is the whole point. + +## Portability + +Multiple machines share this repo (Gentoo sway laptops/desktops, Hyprland +machines, macOS hosts using alacritty, fish shells elsewhere). A change +must not break a platform that stows the affected package. When in doubt +about whether a value is "this machine" or "every machine," the answer +is: put it in the machine-specific section only if it's about that +machine's hardware or role; otherwise it's shared. + +## Git hygiene + +- **This is a public repo. No secrets, ever.** Before every commit: + review `git diff --cached` for tokens, API keys, passwords, private + hostnames/URLs, high-entropy strings. `git diff --cached --check` + catches whitespace, not secrets — an actual grep review of the diff is + required. If in doubt, leave it out and ask. +- Never commit: `*.bak` / `config.bak.*` backups, editor state, lock or + lock-state files, `fish_variables` (per-machine session state, + regenerates on login), anything under `old_config/` or `__pycache__/`. +- `git status` must be clean or intentionally scoped before commit. If + stray files appear, fix the scope (`.gitignore` or exclude) — never + sweep them in, never blanket `git add -A` without reading what's staged. +- Commits: short imperative messages, matching the existing repo style. + Keep diffs minimal and focused; match the comment style and formatting + of the file you're editing. + +## Tool expectancies + +- `waybar/` is the proof-of-principle package for this layout; as other + tools sync in, each gets its own `AGENTS.md` only if it has non-obvious + conventions worth recording. Tmux/nvim/alacritty are synced laptop-first + (laptop wins on divergence) per the conversation that created this + structure. diff --git a/alacritty/.config/alacritty/alacritty.toml.bak b/alacritty/.config/alacritty/alacritty.toml.bak deleted file mode 100644 index 7523299..0000000 --- a/alacritty/.config/alacritty/alacritty.toml.bak +++ /dev/null @@ -1,34 +0,0 @@ -[font] -size = 10 - -[font.normal] -family = "Dejavu Sans Mono" -style = "Regular" - -[window] -opacity = 0.95 - -[window.padding] -x = 5 -y = 5 - -[selection] -save_to_clipboard = true - -# Colors (Doom One) - -# Default colors -[colors.primary] -background = '#282c34' -foreground = '#bbc2cf' - -# Normal colors -[colors.normal] -black = '#282c34' -red = '#ff6c6b' -green = '#98be65' -yellow = '#ecbe7b' -blue = '#51afef' -magenta = '#c678dd' -cyan = '#46d9ff' -white = '#bbc2cf' diff --git a/fish/.config/fish/fish_variables b/fish/.config/fish/fish_variables deleted file mode 100644 index 1bb5feb..0000000 --- a/fish/.config/fish/fish_variables +++ /dev/null @@ -1,104 +0,0 @@ -# This file contains fish universal variable definitions. -# VERSION: 3.0 -SETUVAR __done_min_cmd_duration:10000 -SETUVAR __done_notification_urgency_level:low -SETUVAR __fish_initialized:3800 -SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish -SETUVAR _fisher_plugins:jorgebucaran/nvm\x2efish -SETUVAR _fisher_upgraded_to_4_4:\x1d -SETUVAR fish_color_autosuggestion:brblack -SETUVAR fish_color_cancel:\x2dr -SETUVAR fish_color_command:normal -SETUVAR fish_color_comment:red -SETUVAR fish_color_cwd:green -SETUVAR fish_color_cwd_root:red -SETUVAR fish_color_end:green -SETUVAR fish_color_error:brred -SETUVAR fish_color_escape:brcyan -SETUVAR fish_color_history_current:\x2d\x2dbold -SETUVAR fish_color_host:normal -SETUVAR fish_color_host_remote:yellow -SETUVAR fish_color_normal:normal -SETUVAR fish_color_operator:brcyan -SETUVAR fish_color_param:cyan -SETUVAR fish_color_quote:yellow -SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold -SETUVAR fish_color_search_match:white\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack -SETUVAR fish_color_status:red -SETUVAR fish_color_user:brgreen -SETUVAR fish_color_valid_path:\x2d\x2dunderline -SETUVAR fish_key_bindings:fish_default_key_bindings -SETUVAR fish_pager_color_completion:normal -SETUVAR fish_pager_color_description:yellow\x1e\x2di -SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline -SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan -SETUVAR fish_pager_color_selected_background:\x2dr -SETUVAR fish_user_paths:/home/nicholas/\x2elocal/bin -SETUVAR nvm_default_version:lts -SETUVAR pure_begin_prompt_with_current_directory:true -SETUVAR pure_check_for_new_release:false -SETUVAR pure_color_at_sign:pure_color_mute -SETUVAR pure_color_aws_profile:pure_color_warning -SETUVAR pure_color_command_duration:pure_color_warning -SETUVAR pure_color_current_directory:pure_color_primary -SETUVAR pure_color_danger:red -SETUVAR pure_color_dark:black -SETUVAR pure_color_git_branch:pure_color_mute -SETUVAR pure_color_git_dirty:pure_color_mute -SETUVAR pure_color_git_stash:pure_color_info -SETUVAR pure_color_git_unpulled_commits:pure_color_info -SETUVAR pure_color_git_unpushed_commits:pure_color_info -SETUVAR pure_color_hostname:pure_color_mute -SETUVAR pure_color_info:cyan -SETUVAR pure_color_jobs:pure_color_normal -SETUVAR pure_color_k8s_context:pure_color_success -SETUVAR pure_color_k8s_namespace:pure_color_primary -SETUVAR pure_color_k8s_prefix:pure_color_info -SETUVAR pure_color_light:white -SETUVAR pure_color_mute:brblack -SETUVAR pure_color_nixdevshell_prefix:pure_color_info -SETUVAR pure_color_nixdevshell_symbol:pure_color_mute -SETUVAR pure_color_normal:normal -SETUVAR pure_color_prefix_root_prompt:pure_color_danger -SETUVAR pure_color_primary:blue -SETUVAR pure_color_prompt_on_error:pure_color_danger -SETUVAR pure_color_prompt_on_success:pure_color_success -SETUVAR pure_color_success:magenta -SETUVAR pure_color_system_time:pure_color_mute -SETUVAR pure_color_username_normal:pure_color_mute -SETUVAR pure_color_username_root:pure_color_light -SETUVAR pure_color_virtualenv:pure_color_mute -SETUVAR pure_color_warning:yellow -SETUVAR pure_enable_aws_profile:true -SETUVAR pure_enable_container_detection:true -SETUVAR pure_enable_git:true -SETUVAR pure_enable_k8s:false -SETUVAR pure_enable_nixdevshell:false -SETUVAR pure_enable_single_line_prompt:false -SETUVAR pure_enable_virtualenv:true -SETUVAR pure_reverse_prompt_symbol_in_vimode:true -SETUVAR pure_separate_prompt_on_error:false -SETUVAR pure_shorten_prompt_current_directory_length:0 -SETUVAR pure_shorten_window_title_current_directory_length:0 -SETUVAR pure_show_jobs:false -SETUVAR pure_show_prefix_root_prompt:false -SETUVAR pure_show_subsecond_command_duration:false -SETUVAR pure_show_system_time:false -SETUVAR pure_symbol_aws_profile_prefix: -SETUVAR pure_symbol_container_prefix: -SETUVAR pure_symbol_git_dirty:\x2a -SETUVAR pure_symbol_git_stash:\u2261 -SETUVAR pure_symbol_git_unpulled_commits:\u21e3 -SETUVAR pure_symbol_git_unpushed_commits:\u21e1 -SETUVAR pure_symbol_k8s_prefix:\u2638 -SETUVAR pure_symbol_nixdevshell_prefix:\u2744\ufe0f -SETUVAR pure_symbol_prefix_root_prompt:\x23 -SETUVAR pure_symbol_prompt:\u276f -SETUVAR pure_symbol_reverse_prompt:\u276e -SETUVAR pure_symbol_ssh_prefix: -SETUVAR pure_symbol_title_bar_separator:\x2d -SETUVAR pure_symbol_virtualenv_prefix: -SETUVAR pure_threshold_command_duration:5 -SETUVAR pure_truncate_prompt_current_directory_keeps:\x2d1 -SETUVAR pure_truncate_window_title_current_directory_keeps:\x2d1 diff --git a/waybar/.config/waybar/config.jsonc b/waybar/.config/waybar/config.jsonc new file mode 100644 index 0000000..6e03c31 --- /dev/null +++ b/waybar/.config/waybar/config.jsonc @@ -0,0 +1,109 @@ +{ + "layer": "top", + "position": "top", + "height": 36, + "spacing": 2, + "modules-left": [ + "sway/workspaces", + "sway/mode" + ], + "modules-center": [ + "clock#date", + "clock" + ], + "modules-right": [ + "custom/ppd-glyph", + "battery", + "wireplumber", + "network", + "cpu", + "memory", + "tray" + ], + "sway/workspaces": { + "format": "{name}", + "disable-scroll": true, + "on-click": "activate" + }, + "sway/mode": { + "format": " {}" + }, + "clock": { + "format": "{:%H:%M}", + "tooltip-format": "{:%A %d %B %Y}", + "tooltip": true + }, + "clock#date": { + "format": "{:%m-%d}", + "tooltip-format": "{:%A %d %B %Y}", + "tooltip": true + }, + "custom/ppd-glyph": { + // profile glyph left of the battery icon (ppd-glyph.py): leaf on + // power-saver, rocket on performance, nothing (CSS-collapsed) on + // balanced. Persistent JSONP: the script watches ActiveProfile over the + // system D-Bus and prints one line per change; waybar re-renders per + // newline. restart-interval 0 keeps waybar from ever restarting it. + "exec": "/home/nicholas/.config/waybar/ppd-glyph.py", + "return-type": "json", + "restart-interval": 0 + }, + "battery": { + "interval": 30, + "format": "{icon} {capacity}%", + "format-charging": " {capacity}%", + "format-plugged": " {capacity}%", + "format-not-charging": " {capacity}%", + "format-full": " {capacity}%", + "format-warning": " {capacity}%", + "format-critical": " {capacity}%", + "format-icons": [ + "", + "", + "", + "" + ], + "states": { + "warning": 50, + "critical": 25 + } + }, + "wireplumber": { + "format": "{icon} {volume}%", + "format-muted": " {volume}%", + "format-icons": [ + "", + "", + "" + ], + "tooltip-format": "{node_name}", + "on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle", + "on-scroll-up": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+", + "on-scroll-down": "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" + }, + "network": { + "format-wifi": "{icon} {signaldBm} dBm", + "format-ethernet": " {ifname}", + "format-linked": " {ifname}", + "format-disconnected": "", + "format-icons": [ + "", + "", + "", + "" + ], + "tooltip-format": "{ifname} via {gwaddr}" + }, + "cpu": { + "interval": 5, + "format": " {usage}%" + }, + "memory": { + "interval": 5, + "format": " {percentage}%" + }, + "tray": { + "icon-size": 18, + "spacing": 2 + } +} diff --git a/waybar/.config/waybar/ppd-glyph.py b/waybar/.config/waybar/ppd-glyph.py new file mode 100755 index 0000000..0f02bfd --- /dev/null +++ b/waybar/.config/waybar/ppd-glyph.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +"""waybar custom/ppd-glyph — nerd glyph for the active power profile. + +Leaf (power-saver) and rocket (performance) render just left of the battery +module; balanced renders nothing — CSS (#custom-ppd-glyph.balanced) collapses +the node, so the bar reads identically to before on the vanilla profile. + +Persistent JSONP: prints the current profile once, then watches ActiveProfile +on the *system* bus (org.freedesktop.UPower.PowerProfiles) and re-prints one +JSON line per change; waybar re-renders on every newline. No polling: the +gdbus monitor blocks until something changes; the outer loop restarts it on +bus hiccups, same belt-and-brace as ppd-switch.sh. + +Codepoints were verified against the font's own glyph names (Terminess Nerd +Font md-leaf at U+F032B, md-rocket_launch at U+F14DF) — plausible PUA guesses +like U+F0243/U+F083B turned out to be md-flash_auto / md-television_classic +in this font, so the cmap was read (see the opencode session log) rather +than trusted from memory. +""" + +import json +import re +import subprocess +import sys +import time + +DEST = "org.freedesktop.UPower.PowerProfiles" +OBJPATH = "/org/freedesktop/UPower/PowerProfiles" + +GLYPHS = { + "balanced": "", # stock bar: CSS also collapses the node + "power-saver": "\U000f032b", # md-leaf + "performance": "\U000f14df", # md-rocket-launch +} +TOOLTIPS = { + "balanced": "Balanced (auto: flips to power-saver on battery)", + "power-saver": "Power saver (auto: battery mode)", + "performance": "Performance (manual — sticks through plug/unplug)", +} +# gdbus prints property values as (<'balanced'>,) style S-variants; +# monitor also echoes its own startup banner lines, but extra reads are +# silent under the equality gate, so banners are harmless. +PROFILE_RE = re.compile(r"^.*< *'([a-z][a-z-]*)' *>.*$") + + +def active_profile(): + res = subprocess.run( + ["gdbus", "call", "--system", "--dest", DEST, + "--object-path", OBJPATH, + "--method", "org.freedesktop.DBus.Properties.Get", + DEST, "ActiveProfile"], + capture_output=True, text=True, check=False) + m = PROFILE_RE.search(res.stdout) + return m.group(1) if m else None + + +def emit(profile): + if profile is None: + return # ppd mid-restart; wait for the next Property update instead + print(json.dumps({ + "text": GLYPHS.get(profile, ""), + "class": profile, + "tooltip": TOOLTIPS.get(profile, profile), + }), flush=True) + + +def main(): + last = None + while True: + try: + proc = subprocess.Popen( + ["gdbus", "monitor", "--system", "--dest", DEST], + stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) + for _ in proc.stdout: + cur = active_profile() + if cur != last: + last = cur + emit(cur) + except BrokenPipeError: + return 0 # waybar went away (bar restart/reload); exit quietly + # Anything else (bus blip, monitor SIGSEGV): linger briefly and + # re-loop with a fresh monitor; the equality gate means the bar + # does not re-flash. + try: + proc.terminate() + except Exception: + pass + time.sleep(5) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/waybar/.config/waybar/style.css b/waybar/.config/waybar/style.css new file mode 100644 index 0000000..9b69712 --- /dev/null +++ b/waybar/.config/waybar/style.css @@ -0,0 +1,182 @@ +/* Waybar — doom-one + * bg #282c34 · fg #bbc2cf · blue #51afef · magenta #c678dd + * red #ff6c6b · green #98be65 · yellow #ecbe7b · cyan #46d9ff + * orange #da8548 · violet #a9a1e1 · base3 #3f444a · base5 #5b6268 + */ + +* { + font-family: "Terminess Nerd Font", "Terminess Nerd Font Mono", monospace; + font-size: 15px; + border: none; + border-radius: 0; + min-height: 0; +} + +window#waybar { + background-color: transparent; + border: none; + color: #bbc2cf; +} + +tooltip { + background: #21242b; + border: 1px solid #51afef; + border-radius: 0px; +} + +tooltip label { + color: #bbc2cf; + padding: 4px; +} + +.modules-left, +.modules-center, +.modules-right { + background-color: rgba(40, 44, 52, 0.94); + border: 1px solid #21242b; + border-radius: 0px; + margin: 4px 0; + padding: 0 6px; +} + +.modules-left { + margin-left: 6px; +} + +.modules-right { + margin-right: 6px; +} + +#workspaces, +#mode, +#clock, +#clock.date, +#battery, +#wireplumber, +#network, +#cpu, +#memory, +#tray { + background: transparent; + border: none; + border-radius: 0; + padding: 0 6px; + margin: 0; +} + +#workspaces { + padding: 0; +} + +#workspaces button { + padding: 0 7px; + margin: 4px 2px; + background: transparent; + color: #5b6268; + border-radius: 0px; +} + +#workspaces button.visible { + color: #bbc2cf; +} + +#workspaces button.focused, +#workspaces button.active { + background: #51afef; + color: #282c34; + font-weight: bold; +} + +#workspaces button.urgent { + background: #ff6c6b; + color: #282c34; +} + +#workspaces button:hover { + background: #3f444a; + color: #bbc2cf; +} + +#mode { + background: #da8548; + color: #282c34; + padding: 0 8px; + margin: 4px 2px 4px 6px; + border-radius: 0px; + font-weight: bold; +} + +#clock { + color: #46d9ff; +} + +#clock.date { + color: #a9a1e1; +} + +#battery { + color: #98be65; +} + +#battery.warning { + color: #da8548; +} + +#battery.critical { + color: #ff6c6b; +} + +/* volume widget (wireplumber module): waybar adds both .muted and + * .sink-muted when the sink is muted — style either. */ +#wireplumber { + color: #98be65; +} + +#wireplumber.muted, +#wireplumber.sink-muted { + color: #ff6c6b; +} + +#network { + color: #51afef; +} + +#network.disconnected { + color: #ff6c6b; +} + +#cpu { + color: #da8548; +} + +#memory { + color: #c678dd; +} + +/* ppd profile glyph (ppd-glyph.py): leaf = power-saver, rocket = performance. + * balanced emits an empty label: with padding, min-width and font-size all + * zeroed the module renders zero pixels — note waybar's (GTK-based) CSS + * parser rejects `display: none` as a fatal property error, so the collapse + * must be done the GTK way. */ +#custom-ppd-glyph { + background: transparent; + border: none; + border-radius: 0; + padding: 0; + margin: 0; + min-width: 0; + font-size: 0px; +} + +#custom-ppd-glyph.power-saver, +#custom-ppd-glyph.performance { + font-size: 15px; +} + +#custom-ppd-glyph.power-saver { + color: #98be65; /* green */ +} + +#custom-ppd-glyph.performance { + color: #da8548; /* orange */ +} diff --git a/waybar/.config/waybar/wifi-icon.py b/waybar/.config/waybar/wifi-icon.py new file mode 100755 index 0000000..a39df1a --- /dev/null +++ b/waybar/.config/waybar/wifi-icon.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +"""Print a Nerd Font wifi glyph for the currently associated access point. + +waybar's own {icon} cannot do this. v0.15 turns dBm into a percentage with +a formula that peaks at -45 dBm and then falls off again for *stronger* links, +and it splits that percentage into equal buckets. A great -31 dBm connection +therefore lands in a lower bucket than a mediocre -40 dBm one, so the icon +reads "worse" as you walk towards the router. + +This helper asks nl80211 directly for the associated AP's signal and maps it +onto four glyphs with fixed dBm cut-offs, so the icon rises monotonically with +the link quality. + +Usage: wifi-icon.py [interface] +""" + +import socket +import struct +import sys +import time + +NETLINK_GENERIC = 16 +GENL_ID_CTRL = 16 +NLM_F_REQUEST = 0x001 +NLM_F_DUMP = 0x300 + +NL80211_CMD_GET_SCAN = 32 +NL80211_ATTR_IFINDEX = 3 +NL80211_ATTR_BSS = 47 +NL80211_BSS_SIGNAL_MBM = 7 +NL80211_BSS_STATUS = 9 +NL80211_BSS_STATUS_ASSOCIATED = 1 + +CTRL_CMD_GETFAMILY = 3 +CTRL_ATTR_FAMILY_ID = 1 +CTRL_ATTR_FAMILY_NAME = 2 + +# dBm cut-offs, strongest first. -50 dBm is the usual "excellent" mark, so +# anything from there up (including the -31 dBm you get sitting next to the +# router) shows as full bars. +GLYPHS = ( + (-50, "\U000f0928"), # full + (-60, "\U000f0925"), # good + (-70, "\U000f0922"), # fair + (-90, "\U000f091f"), # weak +) + +TIMEOUT = 2.0 + + +def _attr(atype, payload): + """Build one netlink attribute, padded to a 4 byte boundary.""" + length = 4 + len(payload) + pad = -length % 4 + return struct.pack("=HH", length + pad, atype) + payload + b"\x00" * pad + + +def _parse(data): + """Split a netlink attribute blob into (type, payload) pairs.""" + out = [] + off = 0 + while off + 4 <= len(data): + length, atype = struct.unpack_from("=HH", data, off) + if length < 4: + break + out.append((atype & 0x3FFF, data[off + 4:off + length])) + off += (length + 3) & ~3 + return out + + +def _messages(sock, deadline): + """Yield the payload of every netlink message that arrives in time.""" + while time.monotonic() < deadline: + try: + data = sock.recv(65536) + except socket.timeout: + return + except OSError: + return + off = 0 + while off + 16 <= len(data): + length = struct.unpack_from("=I", data, off)[0] + if length < 16: + break + yield data[off + 16:off + length] + off += (length + 3) & ~3 + + +def _family_id(sock, deadline): + """Ask the kernel for the dynamically assigned 'nl80211' family id.""" + name = _attr(CTRL_ATTR_FAMILY_NAME, b"nl80211\x00") + genl = struct.pack("BBH", CTRL_CMD_GETFAMILY, 0, 0) + payload = genl + name + sock.send(struct.pack("=IHHII", 16 + len(payload), GENL_ID_CTRL, + NLM_F_REQUEST, 1, 0) + payload) + for body in _messages(sock, deadline): + # body is genlmsghdr (4 bytes) followed by the attributes + for atype, payload in _parse(body[4:]): + if atype == CTRL_ATTR_FAMILY_ID: + return struct.unpack("=H", payload[:2])[0] + raise OSError("no nl80211 family id") + + +def _associated_dbm(sock, family, ifindex, deadline): + """Return the signal of the AP we are associated with, in dBm.""" + genl = struct.pack("BBH", NL80211_CMD_GET_SCAN, 0, 0) + attrs = _attr(NL80211_ATTR_IFINDEX, struct.pack("=I", ifindex)) + payload = genl + attrs + sock.send(struct.pack("=IHHII", 16 + len(payload), family, + NLM_F_DUMP, 1, 0) + payload) + for body in _messages(sock, deadline): + for atype, bss in _parse(body[4:]): + if atype != NL80211_ATTR_BSS: + continue + fields = dict(_parse(bss)) + status = fields.get(NL80211_BSS_STATUS) + signal = fields.get(NL80211_BSS_SIGNAL_MBM) + if status is None or signal is None: + continue + if struct.unpack("=I", status)[0] & NL80211_BSS_STATUS_ASSOCIATED: + return struct.unpack("=i", signal)[0] // 100 + return None + + +def main(): + ifname = sys.argv[1] if len(sys.argv) > 1 else "wlan0" + try: + ifindex = socket.if_nametoindex(ifname) + if not ifindex: + return 1 + sock = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, NETLINK_GENERIC) + except OSError: + return 1 + try: + sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1 << 20) + sock.bind((0, 0)) + sock.settimeout(0.5) + deadline = time.monotonic() + TIMEOUT + family = _family_id(sock, deadline) + dbm = _associated_dbm(sock, family, ifindex, deadline) + except (OSError, struct.error): + return 1 + finally: + sock.close() + + if dbm is None: + return 0 + + for threshold, glyph in GLYPHS: + if dbm >= threshold: + print(glyph) + break + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/waybar/config b/waybar/config deleted file mode 100644 index 6bc1e84..0000000 --- a/waybar/config +++ /dev/null @@ -1,35 +0,0 @@ -{ - // "layer": "top", // Waybar at top layer - - // "position": "bottom", // Waybar position (top|bottom|left|right) - - // "height": 30, // Waybar height (to be removed for auto height) - // "width": 1280, // Waybar width - - "spacing": 2, // Gaps between modules (4px) - // Choose the order of the modules - - // Load Modules - "include": [ - "~/.config/waybar/modules.jsonc" - ], - "modules-left": [ - "hyprland/workspaces", - "hyprland/window" - ], - "modules-center": [ - ], - "modules-right": [ - "bluetooth", - "mpd", - "pulseaudio", - "network", - "cpu", - "memory", - "keyboard-state", - "battery", - "clock", - "tray", - "custom/exit" - ] -} diff --git a/waybar/modules.json.bak b/waybar/modules.json.bak deleted file mode 100644 index 9c6eeee..0000000 --- a/waybar/modules.json.bak +++ /dev/null @@ -1,207 +0,0 @@ -// __ __ _ _ -// | \/ | ___ __| |_ _| | ___ ___ -// | |\/| |/ _ \ / _` | | | | |/ _ \/ __| -// | | | | (_) | (_| | |_| | | __/\__ \ -// |_| |_|\___/ \__,_|\__,_|_|\___||___/ -// -// -// by Stephan Raabe (2023) -// ----------------------------------------------------- -// -{ - // Workspaces - "hyprland/workspaces" : { - "on-click": "activate", - "active-only": false, - "all-outputs": true, - "format": "{}", - "format-icons": { - "urgent": "", - "active": "", - "default": "" - }, - "persistent-workspaces": { - "*": 5 - } - }, - - // Hyprland Window - "hyprland/window": { - "rewrite": { - "(.*) - Brave": "$1", - "(.*) - Chromium": "$1", - "(.*) - Brave Search": "$1", - "(.*) - Outlook": "$1", - "(.*) Microsoft Teams": "$1" - }, - "separate-outputs": true - }, - - // Rofi Application Launcher - "custom/appmenu": { - "format": "Apps", - "tooltip-format": "Left: Open the application launcher\nRight: Show all keybindings", - "on-click": "rofi -show drun -replace", - "on-click-right": "~/.config/ml4w/scripts/keybindings.sh", - "tooltip": false - }, - - // Power Menu - "custom/exit": { - "format": "", - "tooltip-format": "Powermenu", - "on-click": "wlogout -b 4", - "tooltip": false - }, - - // Keyboard State - "keyboard-state": { - "numlock": true, - "capslock": true, - "format": "{name} {icon}", - "format-icons": { - "locked": "", - "unlocked": "" - } - }, - - // System tray - "tray": { - // "icon-size": 21, - "spacing": 10 - }, - - // Clock - "clock": { - // "timezone": "America/New_York", - "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>", - "format-alt": "{:%Y-%m-%d}" - }, - - // System - "custom/system": { - "format": "", - "tooltip": false - }, - - // CPU - "cpu": { - "interval": 1, - "format": "C: {usage}%", - "on-click": "alacritty -e btop" - }, - - // Memory - "memory": { - "format": "M {used}G / {total}G ", - "on-click": "alacritty -e htop" - }, - - // Harddisc space used - "disk": { - "interval": 30, - "format": "D {percentage_used}% ", - "path": "/", - "on-click": "alacritty -e htop" - }, - - "hyprland/language": { - "format": "/ K {short}" - }, - - // Group Hardware - "group/hardware": { - "orientation": "inherit", - "drawer": { - "transition-duration": 300, - "children-class": "not-memory", - "transition-left-to-right": false - }, - "modules": [ - "custom/system", - "disk", - "cpu", - "memory", - "hyprland/language" - ] - }, - - // Network - "network": { - "format": "{ifname}", - "format-wifi": " {signalStrength}%", - "format-ethernet": " {ipaddr}", - "format-disconnected": "Not connected", //An empty format will hide the module. - "tooltip-format": " {ifname} via {gwaddri}", - "tooltip-format-wifi": " {essid} ({signalStrength}%)", - "tooltip-format-ethernet": " {ifname} ({ipaddr}/{cidr})", - "tooltip-format-disconnected": "Disconnected", - "max-length": 50, - "on-click": "alacritty -e nmtui-connect" - }, - - // Battery - "battery": { - "states": { - "good": 95, - "warning": 30, - "critical": 15 - }, - "format": "{icon} {capacity}% | {time}", - "format-charging": " {capacity}%", - "format-plugged": " {capacity}%", - "format-alt": "{icon} {time}", - // "format-good": "", // An empty format will hide the module - // "format-full": "", - "format-icons": [" ", " ", " ", " ", " "], - "interval": 5 - }, - - // Pulseaudio - "pulseaudio": { - // "scroll-step": 1, // %, can be a float - "format": "{icon} {volume}%", - "format-bluetooth": "{volume}% {icon} {format_source}", - "format-bluetooth-muted": " {icon} {format_source}", - "format-muted": " {format_source}", - "format-source": "{volume}% ", - "format-source-muted": "", - "format-icons": { - "headphone": "", - "hands-free": "", - "headset": "", - "phone": "", - "portable": "", - "car": "", - "default": ["", " ", " "] - }, - "on-click": "pavucontrol" - }, - - // Bluetooth - "bluetooth": { - "format-disabled": "", - "format-off": "", - "interval": 30, - "on-click": "blueman-manager", - "format-no-controller": "" - }, - - // Other - "user": { - "format": "{user}", - "interval": 60, - "icon": false, - }, - - // Idle Inhibator - "idle_inhibitor": { - "format": "{icon}", - "tooltip": true, - "format-icons":{ - "activated": "", - "deactivated": "" - }, - "on-click-right": "hyprlock" - } -} diff --git a/waybar/modules.jsonc b/waybar/modules.jsonc deleted file mode 100644 index a2aa2f0..0000000 --- a/waybar/modules.jsonc +++ /dev/null @@ -1,84 +0,0 @@ -{ - "layer": "top", - "position": "top", - "modules-left": [ - "hyprland/workspaces" - ], - "modules-center": [ - "clock" - ], - "modules-right": [ - "network", - "pulseaudio", - "backlight", - "battery", - "cpu", - "memory", - "tray", - "custom/lock", - "custom/power" - ], - "hyprland/workspaces": { - "format": "{name}: {icon}", - "format-icons": { - "active": "", - "default": "" - } - }, - "tray": { - "icon-size": 42, - "spacing": 30 - }, - "custom/music": { - "format": " {}", - "escape": true, - "interval": 5, - "tooltip": false, - "exec": "playerctl metadata --format='{{ artist }} - {{ title }}'", - "on-click": "playerctl play-pause", - "max-length": 50 - }, - "clock": { - //"timezone": "America/Sao_Paulo", - "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>", - "format": "{:%m/%d/%Y - %H:%M}" - }, - "bluetooth": { - "on-click": "alacritty -e bluetui" - }, - "network": { - "format-wifi": " {signalStrength}%", - "format-ethernet": "", - "format-disconnected": " No Network", - "interval": 5, - "tooltip": true, - "family": "ipv4", - "tooltip-format": " {ifname} via {gwaddri}", - "tooltip-format-wifi": " {essid} ({signalStrength}%) \n {ifname}: {ipaddr}/{cidr}", - "tooltip-format-ethernet": " {ifname} ({ipaddr}/{cidr})", - "tooltip-format-disconnected": "Disconnected", - "on-click": "alacritty -e nmtui-connect" - }, - "cpu": { - "interval": 1, - "format": " {usage:>2}%" - }, - "memory": { - "interval": 30, - "format": "{used:0.1f}G / {total:0.1f}G", - "on-click": "alacritty -e btop", - "tooltip": true - }, - "pulseaudio": { - "format": "{icon} {volume}%", - "format-muted": "", - "format-icons": { - "default": [ - "", - "", - " " - ] - }, - "on-click": "pavucontrol" - } -} diff --git a/waybar/style.css b/waybar/style.css deleted file mode 100644 index 7db2f56..0000000 --- a/waybar/style.css +++ /dev/null @@ -1,117 +0,0 @@ -* { - font-family: JetbrainsMono Nerd Font; - font-size: 12px; - min-height: 0; - padding-right: 2px; - padding-left: 2px; - padding-bottom: 0px; -} - -#waybar { - background: transparent; - color: #c6d0f5; - margin: 2px 2px; -} - -#workspaces { - border-radius: 5px; - margin: 5px; - background: #101010; - margin-left: 1rem; -} - -#workspaces button { - color: #babbf1; - border-radius: 5px; - padding: 0.4rem; -} - -#workspaces button.active { - color: #99d1db; - border-radius: 5px; -} - -#workspaces button:hover { - color: #85c1dc; - border-radius: 5px; -} - -#network, -#custom-music, -#tray, -#backlight, -#clock, -#battery, -#pulseaudio, -#cpu, -#memory, -#custom-lock, -#custom-power { - background-color: #101010; - padding: 0.5rem 1rem; - margin: 5px 0; -} - -#memory { - border-radius: 0px 0px 0px 0px; -} - -#clock { - color: #8caaee; - border-radius: 5px; - margin-right: 1rem; -} - -#battery { - color: #a6d189; -} - -#battery.charging { - color: #a6d189; -} - -#battery.warning:not(.charging) { - color: #e78284; -} - -#backlight { - color: #e5c890; -} - -#backlight, -#battery { - border-radius: 0; -} - -#bluetooth, #bluetooth.on, #bluetooth.connected #bluetooth.disabled #bluetooth.off { - border-radius: 0px 0px 0px 0%; - margin-left: 1rem; -} - -#pulseaudio { - color: #ea999c; - border-radius: 0px 0px 0px 0%; - margin-left: 1rem; -} - -#custom-music { - color: #ca9ee6; - border-radius: 5px; -} - -#custom-lock { - border-radius: 5px 0px 0px 5px; - color: #babbf1; -} - -#custom-power { - margin-right: 1rem; - border-radius: 0px 5px 5px 0px; - color: #e78284; -} - -#tray { - margin-right: 1rem; - margin-left: 1rem; - border-radius: 5px; -} diff --git a/waybar/style.css.bak b/waybar/style.css.bak deleted file mode 100644 index 38e0d92..0000000 --- a/waybar/style.css.bak +++ /dev/null @@ -1,357 +0,0 @@ -/* - * __ __ _ ____ _ _ - * \ \ / /_ _ _ _| |__ __ _ _ __ / ___|| |_ _ _| | ___ - * \ \ /\ / / _` | | | | '_ \ / _` | '__| \___ \| __| | | | |/ _ \ - * \ V V / (_| | |_| | |_) | (_| | | ___) | |_| |_| | | __/ - * \_/\_/ \__,_|\__, |_.__/ \__,_|_| |____/ \__|\__, |_|\___| - * |___/ |___/ - * - * by Stephan Raabe (2024) - * ----------------------------------------------------- -*/ - -@define-color backgroundlight #FFFFFF; -@define-color backgrounddark #FFFFFF; -@define-color workspacesbackground1 #FFFFFF; -@define-color workspacesbackground2 #CCCCCC; -@define-color bordercolor #FFFFFF; -@define-color textcolor1 #000000; -@define-color textcolor2 #000000; -@define-color textcolor3 #FFFFFF; -@define-color iconcolor #FFFFFF; - -/* ----------------------------------------------------- - * General - * ----------------------------------------------------- */ - -* { - font-family: "Hack", FontAwesome, Roboto, Helvetica, Arial, sans-serif; - font-size: 10px; - border: none; - border-radius: 0px; -} - -window#waybar { - background-color: rgba(0,0,0,0.2); - border-bottom: 0px solid #ffffff; - /* color: #FFFFFF; */ - transition-property: background-color; - transition-duration: .5s; -} - -/* ----------------------------------------------------- - * Workspaces - * ----------------------------------------------------- */ - -#workspaces { - margin: 10px 15px 10px 0px; - padding: 0px 0px; - border-radius: 0px; - border: 0px; - font-weight: bold; - font-style: normal; - font-size: 10px; - color: @textcolor1; -} - -#workspaces button { - padding: 0px 0px; - margin: 4px 3px; - border-radius: 0px; - border: 0px; - color: @textcolor3; - transition: all 0.3s ease-in-out; -} - -#workspaces button.active { - color: @textcolor1; - background: @workspacesbackground2; - border-radius: 0px; - min-width: 10px; - transition: all 0.3s ease-in-out; -} - -#workspaces button:hover { - color: @textcolor1; - background: @workspacesbackground2; - border-radius: 0px; -} - -/* ----------------------------------------------------- - * Tooltips - * ----------------------------------------------------- */ - -tooltip { - border-radius: 10px; - background-color: @backgroundlight; - opacity:0.8; - padding:20px; - margin:0px; -} - -tooltip label { - color: @textcolor2; -} - -/* ----------------------------------------------------- - * Window - * ----------------------------------------------------- */ - -#window { - background: @backgroundlight; - margin: 10px 15px 10px 0px; - padding: 2px 10px 0px 10px; - border-radius: 0px; - color:@textcolor2; - font-size:10px; - font-weight:normal; -} - -window#waybar.empty #window { - background-color:transparent; -} - -/* ----------------------------------------------------- - * Taskbar - * ----------------------------------------------------- */ - -#taskbar { - background: @backgroundlight; - margin: 6px 15px 6px 0px; - padding:0px; - border-radius: 0px; - font-weight: normal; - font-style: normal; - border: 3px solid @backgroundlight; -} - -#taskbar button { - margin:0; - border-radius: 0px; - padding: 0px 5px 0px 5px; -} - -/* ----------------------------------------------------- - * Modules - * ----------------------------------------------------- */ - -.modules-left > widget:first-child > #workspaces { - margin-left: 0; -} - -.modules-right > widget:last-child > #workspaces { - margin-right: 0; -} - -/* ----------------------------------------------------- - * Custom Quicklinks - * ----------------------------------------------------- */ - -#custom-browser, -#custom-filemanager, -#network, -#pulseaudio, -#battery, -#custom-appmenu, -#clock { - margin-right: 20px; - font-size: 10px; - font-weight: bold; - color: @iconcolor; - padding: 4px 10px 2px 10px; - font-size: 10px; -} - -#custom-quicklink1, -#custom-quicklink2, -#custom-quicklink3, -#custom-quicklink4, -#custom-quicklink5, -#custom-quicklink6, -#custom-quicklink7, -#custom-quicklink8, -#custom-quicklink9, -#custom-quicklink10 { - padding:0px; - margin-right: 7px; - font-size:10px; - color: @iconcolor; -} - -/* ----------------------------------------------------- - * Custom Modules - * ----------------------------------------------------- */ - -#custom-appmenu { - background-color: @backgrounddark; - color: @textcolor1; - border-radius: 15px; - margin: 10px 10px 10px 10px; -} - -/* ----------------------------------------------------- - * Custom Exit - * ----------------------------------------------------- */ - -#custom-exit { - margin: 2px 20px 0px 0px; - padding:0px; - font-size:10px; - color: @iconcolor; -} - -/* ----------------------------------------------------- - * Hardware Group - * ----------------------------------------------------- */ - - #disk,#memory,#cpu,#language { - margin:0px; - padding:0px; - font-size:10px; - color:@iconcolor; -} - -#language { - margin-right:10px; -} - -/* ----------------------------------------------------- - * Clock - * ----------------------------------------------------- */ - -#clock { - background-color: @backgrounddark; - font-size: 10px; - color: @textcolor1; - border-radius: 0px; - margin: 10px 7px 10px 0px; -} - -/* ----------------------------------------------------- - * Pulseaudio - * ----------------------------------------------------- */ - -#pulseaudio { - background-color: @backgroundlight; - font-size: 10px; - color: @textcolor2; - border-radius: 0px; - margin: 10px 10px 10px 0px; -} - -#pulseaudio.muted { - background-color: @backgrounddark; - color: @textcolor1; -} - -/* ----------------------------------------------------- - * Network - * ----------------------------------------------------- */ - -#network { - background-color: @backgroundlight; - font-size: 10px; - color: @textcolor2; - border-radius: 0px; - margin: 10px 10px 10px 0px; -} - -#network.ethernet { - background-color: @backgroundlight; - color: @textcolor2; -} - -#network.wifi { - background-color: @backgroundlight; - color: @textcolor2; -} - -/* ----------------------------------------------------- - * Bluetooth - * ----------------------------------------------------- */ - - #bluetooth, #bluetooth.on, #bluetooth.connected { - background-color: @backgroundlight; - font-size: 10px; - color: @textcolor2; - border-radius: 0px; - margin: 10px 15px 10px 0px; -} - -#bluetooth.off { - background-color: transparent; - padding: 0px; - margin: 0px; -} - -/* ----------------------------------------------------- - * Battery - * ----------------------------------------------------- */ - -#battery { - background-color: @backgroundlight; - font-size: 10px; - color: @textcolor2; - border-radius: 0px; - margin: 10px 15px 10px 0px; -} - -#battery.charging, #battery.plugged { - color: @textcolor2; - background-color: @backgroundlight; -} - -@keyframes blink { - to { - background-color: @backgroundlight; - color: @textcolor2; - } -} - -#battery.critical:not(.charging) { - background-color: #f53c3c; - color: @textcolor3; - animation-name: blink; - animation-duration: 0.5s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; -} - -/* ----------------------------------------------------- - * Tray - * ----------------------------------------------------- */ - -#tray { - margin:0px 10px 0px 0px; -} - -#tray > .passive { - -gtk-icon-effect: dim; -} - -#tray > .needs-attention { - -gtk-icon-effect: highlight; - background-color: #eb4d4b; -} - -/* ----------------------------------------------------- - * Other - * ----------------------------------------------------- */ - -label:focus { - background-color: #000000; -} - -#backlight { - background-color: #90b1b1; -} - -#network { - background-color: #2980b9; -} - -#network.disconnected { - background-color: #f53c3c; -} - |
