aboutsummaryrefslogtreecommitdiff
path: root/.config/swayrbar
diff options
context:
space:
mode:
Diffstat (limited to '.config/swayrbar')
-rw-r--r--.config/swayrbar/config.toml107
-rwxr-xr-x.config/swayrbar/scripts/brightness-status23
-rwxr-xr-x.config/swayrbar/scripts/idle-status10
-rwxr-xr-x.config/swayrbar/scripts/idle-toggle11
-rwxr-xr-x.config/swayrbar/scripts/temp-status6
-rwxr-xr-x.config/swayrbar/scripts/wayland-idle-inhibitor.py95
6 files changed, 252 insertions, 0 deletions
diff --git a/.config/swayrbar/config.toml b/.config/swayrbar/config.toml
new file mode 100644
index 0000000..a0aa955
--- /dev/null
+++ b/.config/swayrbar/config.toml
@@ -0,0 +1,107 @@
+refresh_interval = 1000
+
+[[modules]]
+name = "window"
+instance = "0"
+format = "๐ŸชŸ {title} โ€” {app_name}"
+html_escape = false
+
+[modules.on_click]
+Left = [
+ "swayr",
+ "switch-to-urgent-or-lru-window",
+]
+Right = [
+ "kill",
+ "{pid}",
+]
+
+[[modules]]
+name = "cmd"
+instance = "0"
+format = "{HOME}/.config/swayrbar/scripts/idle-status"
+html_escape = false
+
+[modules.on_click]
+Left = ["{HOME}/.config/swayrbar/scripts/idle-toggle"]
+
+[[modules]]
+name = "sysinfo"
+instance = "0"
+format = "๎‰ฆ CPU: {cpu_usage:{:5.1}}% Mem: {mem_usage:{:5.1}}%"
+html_escape = false
+
+[modules.on_click]
+Left = [
+ "foot",
+ "htop",
+]
+
+[[modules]]
+name = "battery"
+instance = "0"
+format = "๐Ÿ”‹ {state_of_charge:{:5.1}}%, {state}"
+html_escape = false
+
+[[modules]]
+name = "pactl"
+instance = "0"
+format = "๐Ÿ”ˆ{volume:{:3}}%{muted}"
+html_escape = true
+
+[[modules]]
+name = "nmcli"
+instance = "0"
+format = "๓ฐคจ {name} {signal}"
+html_escape = true
+
+[modules.on_click]
+Right = [
+ "pactl",
+ "set-sink-mute",
+ "@DEFAULT_SINK@",
+ "toggle",
+]
+WheelDown = [
+ "pactl",
+ "set-sink-volume",
+ "@DEFAULT_SINK@",
+ "-1%",
+]
+Left = ["pavucontrol"]
+WheelUp = [
+ "pactl",
+ "set-sink-volume",
+ "@DEFAULT_SINK@",
+ "+1%",
+]
+
+[[modules]]
+name = "cmd"
+instance = "1"
+format = "{HOME}/.config/swayrbar/scripts/brightness-status"
+html_escape = false
+
+[modules.on_click]
+WheelUp = [
+ "brightnessctl",
+ "set",
+ "5%+",
+]
+WheelDown = [
+ "brightnessctl",
+ "set",
+ "5%-",
+]
+
+[[modules]]
+name = "cmd"
+instance = "2"
+format = "{HOME}/.config/swayrbar/scripts/temp-status"
+html_escape = false
+
+[[modules]]
+name = "date"
+instance = "0"
+format = "๓ฑ‘† %F %X"
+html_escape = false
diff --git a/.config/swayrbar/scripts/brightness-status b/.config/swayrbar/scripts/brightness-status
new file mode 100755
index 0000000..562ee62
--- /dev/null
+++ b/.config/swayrbar/scripts/brightness-status
@@ -0,0 +1,23 @@
+#!/usr/bin/env sh
+
+brightness_path=/sys/class/backlight/*/brightness
+brightness_max_path=/sys/class/backlight/*/max_brightness
+
+if [ -f "${brightness_path}" ]
+then
+ brightness="$(cat $brightness_path)"
+fi
+
+if [ -f "${brightness_max_path}" ]
+then
+ brightness_max="$(cat /sys/class/backlight/*/max_brightness)"
+fi
+
+if [ -n "${brightness}" ] && [ -n "${brightness_max}" ]
+then
+ level=$(echo "scale=2; $brightness / $brightness_max * 100" | bc)
+
+ printf "๏‚ "
+ printf "%.0f\n" $level
+fi
+
diff --git a/.config/swayrbar/scripts/idle-status b/.config/swayrbar/scripts/idle-status
new file mode 100755
index 0000000..9420e64
--- /dev/null
+++ b/.config/swayrbar/scripts/idle-status
@@ -0,0 +1,10 @@
+#!/usr/bin/env sh
+pid_file="/tmp/wayland-idle-inhibitor-$(id --user).pid"
+pid=$(cat "${pid_file}")
+if [ -n "${pid}" ] && kill -0 "${pid}"
+then
+ echo -n "๏ฎ "
+else
+ echo -n "๏ฐ "
+fi
+
diff --git a/.config/swayrbar/scripts/idle-toggle b/.config/swayrbar/scripts/idle-toggle
new file mode 100755
index 0000000..fd1a796
--- /dev/null
+++ b/.config/swayrbar/scripts/idle-toggle
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+pid_file="/tmp/wayland-idle-inhibitor-$(id --user).pid"
+pid=$(cat "${pid_file}")
+if [ -n "${pid}" ]
+then
+ kill -- "${pid}"
+ rm "${pid_file}"
+else
+ nohup "${HOME}/.config/swayrbar/scripts/wayland-idle-inhibitor.py" > /dev/null 2>&1 & echo $! > "${pid_file}"
+fi
+
diff --git a/.config/swayrbar/scripts/temp-status b/.config/swayrbar/scripts/temp-status
new file mode 100755
index 0000000..60220d2
--- /dev/null
+++ b/.config/swayrbar/scripts/temp-status
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+temps="$(cat /sys/class/hwmon/hwmon*/temp*_input)"
+temp=$(echo \("$(echo -n "$temps" | tr '\n' '+')) / $(echo "$temps" | wc -l) / 1000" | bc)
+
+echo -n "$temp" ยฐC
diff --git a/.config/swayrbar/scripts/wayland-idle-inhibitor.py b/.config/swayrbar/scripts/wayland-idle-inhibitor.py
new file mode 100755
index 0000000..6ce90cf
--- /dev/null
+++ b/.config/swayrbar/scripts/wayland-idle-inhibitor.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# Version 2, December 2004
+
+# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+# Everyone is permitted to copy and distribute verbatim or modified
+# copies of this license document, and changing it is allowed as long
+# as the name is changed.
+
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+# 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+
+import sys
+from dataclasses import dataclass
+from signal import SIGINT, SIGTERM, signal
+from threading import Event
+
+from pywayland.client.display import Display
+from pywayland.protocol.idle_inhibit_unstable_v1.zwp_idle_inhibit_manager_v1 import (
+ ZwpIdleInhibitManagerV1,
+)
+from pywayland.protocol.wayland.wl_compositor import WlCompositor
+from pywayland.protocol.wayland.wl_registry import WlRegistryProxy
+from pywayland.protocol.wayland.wl_surface import WlSurface
+
+
+@dataclass
+class GlobalRegistry:
+ surface: WlSurface | None = None
+ inhibit_manager: ZwpIdleInhibitManagerV1 | None = None
+
+
+def handle_registry_global(
+ wl_registry: WlRegistryProxy, id_num: int, iface_name: str, version: int
+) -> None:
+ global_registry: GlobalRegistry = wl_registry.user_data or GlobalRegistry()
+
+ if iface_name == "wl_compositor":
+ compositor = wl_registry.bind(id_num, WlCompositor, version)
+ global_registry.surface = compositor.create_surface() # type: ignore
+ elif iface_name == "zwp_idle_inhibit_manager_v1":
+ global_registry.inhibit_manager = wl_registry.bind(
+ id_num, ZwpIdleInhibitManagerV1, version
+ )
+
+
+def main() -> None:
+ done = Event()
+ signal(SIGINT, lambda _, __: done.set())
+ signal(SIGTERM, lambda _, __: done.set())
+
+ global_registry = GlobalRegistry()
+
+ display = Display()
+ display.connect()
+
+ registry = display.get_registry() # type: ignore
+ registry.user_data = global_registry
+ registry.dispatcher["global"] = handle_registry_global
+
+ def shutdown() -> None:
+ display.dispatch()
+ display.roundtrip()
+ display.disconnect()
+
+ display.dispatch()
+ display.roundtrip()
+
+ if global_registry.surface is None or global_registry.inhibit_manager is None:
+ print("Wayland seems not to support idle_inhibit_unstable_v1 protocol.")
+ shutdown()
+ sys.exit(1)
+
+ inhibitor = global_registry.inhibit_manager.create_inhibitor( # type: ignore
+ global_registry.surface
+ )
+
+ display.dispatch()
+ display.roundtrip()
+
+ print("Inhibiting idle...")
+ done.wait()
+ print("Shutting down...")
+
+ inhibitor.destroy()
+
+ shutdown()
+
+
+if __name__ == "__main__":
+ main()