From 283a649486e30b556d6a76a3973755294b7aa593 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sat, 9 Aug 2025 15:32:12 +0200 Subject: [PATCH] added modules to waybar --- fish/fish_variables | 4 +- fish/functions/convert_discord.fish | 3 + fuzzel/fuzzel.ini | 10 +- hypr/modules/autostart.conf | 6 +- hypr/modules/keybinds.conf | 6 +- hypr/scripts/replay-ctrl.sh | 70 ++++++++ .../restart_xdg-desktop-portal-hyprland.sh | 7 + waybar/config.jsonc | 53 ++++-- waybar/scripts/gamemode_status.sh | 7 + waybar/scripts/gpu-screen-recorder-status.sh | 18 ++ waybar/scripts/gpu_usage.sh | 19 +++ waybar/scripts/toggle-replay.sh | 9 + waybar/style.css | 37 ++++- waybar/style.css-without-borders | 157 ------------------ waybar/style.css.bak | 81 --------- 15 files changed, 223 insertions(+), 264 deletions(-) create mode 100644 fish/functions/convert_discord.fish create mode 100755 hypr/scripts/replay-ctrl.sh create mode 100755 hypr/scripts/restart_xdg-desktop-portal-hyprland.sh create mode 100755 waybar/scripts/gamemode_status.sh create mode 100755 waybar/scripts/gpu-screen-recorder-status.sh create mode 100755 waybar/scripts/gpu_usage.sh create mode 100755 waybar/scripts/toggle-replay.sh delete mode 100644 waybar/style.css-without-borders delete mode 100644 waybar/style.css.bak diff --git a/fish/fish_variables b/fish/fish_variables index 00ac844..4e1873f 100644 --- a/fish/fish_variables +++ b/fish/fish_variables @@ -5,8 +5,8 @@ SETUVAR DATABASE_URL:sqlite\x3adatabase\x2esqlite SETUVAR GLFW_IM_MODULE:ibus SETUVAR MANPAGER:sh\x20\x2dc\x20\x27col\x20\x2dbx\x20\x7c\x20bat\x20\x2dl\x20man\x20\x2dp\x27 SETUVAR RUST_LOG:debug -SETUVAR --export SSH_AGENT_PID:36174 -SETUVAR --export SSH_AUTH_SOCK:/tmp/ssh\x2dXXXXXXVGqONj/agent\x2e36173 +SETUVAR --export SSH_AGENT_PID:1385 +SETUVAR --export SSH_AUTH_SOCK:/tmp/ssh\x2dXXXXXXbvMvPU/agent\x2e1384 SETUVAR SXHKD_SHELL:/usr/bin/bash SETUVAR ZO_CMD:zo SETUVAR Z_CMD:z diff --git a/fish/functions/convert_discord.fish b/fish/functions/convert_discord.fish new file mode 100644 index 0000000..1c48b76 --- /dev/null +++ b/fish/functions/convert_discord.fish @@ -0,0 +1,3 @@ +function convert_discord --wraps='ffmpeg -i -s 1280x720 -discord.mp4' --description 'alias convert_discord=ffmpeg -i -s 1280x720 -discord.mp4' + ffmpeg -i $argv[1] -s 1280x720 (string split -r -m1 . $argv[1])[1]-discord.mp4; +end diff --git a/fuzzel/fuzzel.ini b/fuzzel/fuzzel.ini index de0d06f..13911e0 100644 --- a/fuzzel/fuzzel.ini +++ b/fuzzel/fuzzel.ini @@ -1,5 +1,13 @@ include=~/.config/fuzzel/catppuccin-fuzzel/themes/catppuccin-mocha/mauve.ini [main] -font=FiraCode Nerd Font:size=12 +font=FiraCode Nerd Font:size=14 terminal=alacritty +dpi-aware=no +prompt="> " +icon-theme=Papirus-Dark +show-actions=yes + +[border] +radius=4 +width=2 diff --git a/hypr/modules/autostart.conf b/hypr/modules/autostart.conf index 0012abd..e2acf0e 100644 --- a/hypr/modules/autostart.conf +++ b/hypr/modules/autostart.conf @@ -3,9 +3,11 @@ # Or execute your favorite apps at launch like this: # exec-once = uwsm app -- waybar -exec-once = uwsm app -- nm-applet # exec-once = uwsm app -- nextcloud --background +exec-once = uwsm app -- nm-applet exec-once = uwsm app -- rclone mount google_drive: ~/gdrive exec-once = uwsm app -- protonvpn-app exec-once = uwsm app -- hyprpaper -exec-once = uwsm app -- sh -c "/usr/bin/discord discord --enable-features=UseOzonePlatform --ozone-platform=wayland --start-minimized &> /dev/null" +exec-once = uwsm app -- /usr/bin/discord --enable-features=UseOzonePlatform --ozone-platform=wayland --start-minimized &> /dev/null +exec-once = uwsm app -- sleep 5 && ~/.config/hypr/scripts/replay-ctrl.sh start +# exec-once = uwsm app -- /usr/lib/xdg-desktop-portal-hyprland diff --git a/hypr/modules/keybinds.conf b/hypr/modules/keybinds.conf index 2ed7965..2b62a05 100644 --- a/hypr/modules/keybinds.conf +++ b/hypr/modules/keybinds.conf @@ -1,10 +1,12 @@ $mainMod = SUPER # Sets "Windows" key as main modifier -bind = , PRINT, exec, gscreenshot -c -s +bind = , PRINT, exec, grim -g "$(slurp)" - | wl-copy & +bindr = ALT SHIFT, z, exec, ~/.config/hypr/scripts/replay-ctrl.sh save & +# bind = , PRINT, exec, gscreenshot -c -s bind = $mainMod, RETURN, exec, $terminal bind = $mainMod SHIFT, Q, killactive, -bind = $mainMod CTRL, L, exec, hyprlock +bind = $mainMod CTRL, L, exec, hyprlock & bind = $mainMod, E, exec, $fileManager bind = $mainMod, V, togglefloating, bind = $mainMod, F, fullscreen, diff --git a/hypr/scripts/replay-ctrl.sh b/hypr/scripts/replay-ctrl.sh new file mode 100755 index 0000000..3ba5504 --- /dev/null +++ b/hypr/scripts/replay-ctrl.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +PROGRAM_NAME="gpu-screen-recorder" +PID_FILE="/tmp/gpu-screen-recorder.pid" + +start() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is already active." + exit 0 + fi + fi + + video_path="$HOME/Videos/replay/" + mkdir -p "$video_path" + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is starting ..." + gpu-screen-recorder -w screen -f 60 -a default_output -c mkv -bm qp -cr full -tune quality -k av1_10bit -q high -r 120 -replay-storage ram -ab 320 -o "$video_path" & + echo $! > "$PID_FILE" +} + +stop() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + kill "$PID" + rm "$PID_FILE" + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME has been stopped." + else + rm "$PID_FILE" # Stale PID file + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is not running." + fi + else + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is not running." + fi +} + +save() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + pkill -SIGUSR1 -f gpu-screen-recorder && sleep 0.5 && notify-send -u low "$PROGRAM_NAME" "Saving replay..." + else + # The process is not running, but the PID file exists. + # This can happen if the process crashed. + # We'll remove the stale PID file. + rm "$PID_FILE" + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is not running." + fi + else + notify-send -u low "$PROGRAM_NAME" "$PROGRAM_NAME is not running." + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + save) + save + ;; + *) + echo "Usage: $0 {start|stop|save}" + exit 1 +esac + +exit 0 diff --git a/hypr/scripts/restart_xdg-desktop-portal-hyprland.sh b/hypr/scripts/restart_xdg-desktop-portal-hyprland.sh new file mode 100755 index 0000000..15772d9 --- /dev/null +++ b/hypr/scripts/restart_xdg-desktop-portal-hyprland.sh @@ -0,0 +1,7 @@ +#!/bin/sh +sleep 1 +killall -e xdg-desktop-portal-hyprland +killall xdg-desktop-portal +/usr/lib/xdg-desktop-portal-hyprland & +sleep 2 +/usr/lib/xdg-desktop-portal & diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 4699e5b..a0e4c45 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -3,19 +3,25 @@ "layer": "top", "position": "top", "height": 35, - "modules-left": ["hyprland/workspaces"], + "modules-left": [ + "hyprland/workspaces" + ], "modules-center": [], - "modules-right": ["tray", + "modules-right": [ "wireplumber", "custom/audio-output", "custom/pixelbuds", "custom/anc", "network", + "custom/gpu-usage", "cpu", - "memory", - "clock", + "memory", + "custom/gpu-usage", + "custom/gpu-screen-recorder", "custom/gamemode", - "custom/power" + "tray", + "clock" + // "custom/power" ], "hyprland/workspaces": { @@ -29,14 +35,20 @@ "clock": { "format": "{:%H:%M}", "format-alt": "{:%a, %b %d}", - "tooltip-format": "{:%Y %B}\n{calendar}" + "on-click-right": "xdg-open https://calendar.proton.me/u/0/month &> /dev/null & disown" + }, + "custom/gpu": { + "format": "GPU: {}%", + "exec": "~/.config/waybar/scripts/gpu_usage.sh", + "interval": 1, + "tooltip": true }, "cpu": { "format": "CPU: {usage}%", "tooltip": true }, "memory": { - "format": "MEM: {}%" + "format": "MEM: {used}/{total}GB" }, "network": { "format-wifi": "{essid} ({signalStrength}%): {ipaddr}", @@ -101,14 +113,14 @@ "format": "{}", "return-type": "json", "exec": "~/.config/waybar/scripts/pixelbuds.sh", - "interval": 5, + "interval": 1, "on-click": "bluetoothctl disconnect B4:23:A2:09:D3:53" }, "custom/anc": { "format": "{}", "return-type": "json", "exec": "~/.config/waybar/scripts/anc_control.sh", - "interval": 5, + "interval": 1, "on-click": "~/.config/waybar/scripts/anc_control.sh off", "on-click-right": "~/.config/waybar/scripts/anc_control.sh cycle" }, @@ -120,7 +132,24 @@ "interval": 1 }, "custom/gamemode": { - "format": "󰮂", - "on-click": "~/.config/hypr/scripts/gamemode.sh" - } + "format": "{}", + "return-type": "json", + "exec": "~/.config/waybar/scripts/gamemode_status.sh", + "on-click": "~/.config/hypr/scripts/gamemode.sh", + "interval": 1 + }, + "custom/gpu-screen-recorder": { + "format": "{}", + "return-type": "json", + "exec": "~/.config/waybar/scripts/gpu-screen-recorder-status.sh", + "on-click-right": "~/.config/hypr/scripts/replay-ctrl.sh save", + "on-click": "~/.config/waybar/scripts/toggle-replay.sh", + "interval": 1 + }, + "custom/gpu-usage": { + "format": "{}", + "return-type": "json", + "exec": "~/.config/waybar/scripts/gpu_usage.sh", + "interval": 5 + } } diff --git a/waybar/scripts/gamemode_status.sh b/waybar/scripts/gamemode_status.sh new file mode 100755 index 0000000..8079ef7 --- /dev/null +++ b/waybar/scripts/gamemode_status.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}') +if [ "$HYPRGAMEMODE" = 1 ] ; then + echo '{"text": "Gamemode", "tooltip": "Gamemode deactivated"}' +else + echo '{"text": "Gamemode", "tooltip": "Gamemode activated", "class": "active"}' +fi diff --git a/waybar/scripts/gpu-screen-recorder-status.sh b/waybar/scripts/gpu-screen-recorder-status.sh new file mode 100755 index 0000000..ad498d0 --- /dev/null +++ b/waybar/scripts/gpu-screen-recorder-status.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +PID_FILE="/tmp/gpu-screen-recorder.pid" + +if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + echo '{"text": "Replay", "tooltip": "Replay running", "class": "recording"}' + else + # The process is not running, but the PID file exists. + # This can happen if the process crashed. + # We'll remove the stale PID file. + rm "$PID_FILE" + echo '{"text": "Replay", "tooltip": "Replay paused"}' + fi +else + echo '{"text": "Replay", "tooltip": "Replay paused"}' +fi diff --git a/waybar/scripts/gpu_usage.sh b/waybar/scripts/gpu_usage.sh new file mode 100755 index 0000000..49a7d0c --- /dev/null +++ b/waybar/scripts/gpu_usage.sh @@ -0,0 +1,19 @@ +#!/bin/bash +USAGE=$(cat /sys/class/drm/card1/device/gpu_busy_percent) +MEM_USED=$(cat /sys/class/drm/card1/device/mem_info_vram_used) +MEM_TOTAL=$(cat /sys/class/drm/card1/device/mem_info_vram_total) +GPU=$(/opt/rocm/bin/rocm-smi --showproductname | grep "Card Series" | awk -F':' '{print $3}' | xargs) +TEXT="$USAGE% $(printf "%.2f\n" $(echo "scale=2; $MEM_USED/1024/1024/1024" | bc -l))/$(echo "scale=2; $MEM_TOTAL/1024/1024/1024" | bc -l)GB" +RATIO=$(echo "$MEM_USED/ $MEM_TOTAL" | bc -l) + +CLASS="" + +if (( $(echo "$USAGE > 95" | bc -l) )); then + CLASS="max_usage" +elif (( $(echo "$USAGE > 75" | bc -l) )); then + CLASS="high_usage" +else + CLASS="normal_usage" +fi + +echo "{\"text\":\"GPU: $TEXT\", \"tooltip\": \"$GPU\", \"class\":\"$CLASS\"}" diff --git a/waybar/scripts/toggle-replay.sh b/waybar/scripts/toggle-replay.sh new file mode 100755 index 0000000..412eeb3 --- /dev/null +++ b/waybar/scripts/toggle-replay.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +PID_FILE="/tmp/gpu-screen-recorder.pid" + +if [ -f "$PID_FILE" ] && ps -p "$(cat "$PID_FILE")" > /dev/null; then + $HOME/.config/hypr/scripts/replay-ctrl.sh stop +else + $HOME/.config/hypr/scripts/replay-ctrl.sh start +fi diff --git a/waybar/style.css b/waybar/style.css index 432fd48..b91d0cc 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -55,6 +55,7 @@ window#waybar.hidden { #memory, #cpu, +#custom-gpu-usage, #custom-power, #custom-gamemode, #custom-tlp, @@ -66,10 +67,11 @@ window#waybar.hidden { #tray, #custom-pixelbuds, #custom-anc, -#custom-audio-output { +#custom-audio-output, +#custom-gpu-screen-recorder { border-radius: 4px; margin: 6px 3px; - padding: 6px 12px; + padding: 6px 16px 6px 12px; background-color: @base; color: @text; } @@ -92,10 +94,19 @@ window#waybar.hidden { #custom-anc.disconnected { } -#custom-power, +#custom-gpu-screen-recorder, #custom-gamemode { + border-bottom: 3px solid @text; +} + +#custom-power { color: @red; - padding: 6px 12px 6px 10px; +} + +#custom-gpu-screen-recorder.recording, +#custom-gamemode.active { + color: @red; + border-bottom: 3px solid @red; } #custom-tlp { @@ -136,10 +147,21 @@ window#waybar.hidden { } } +#custom-gpu-usage.max_usage { + color: @maroon; +} + +#custom-gpu-usage.high_usage { + color: @yellow; +} + +#custom-gpu-usage.normal_usage { + color: @teal; +} + #memory, #cpu { - color: @maroon; - border-bottom: 3px solid @maroon; + color: @teal; } @@ -165,7 +187,8 @@ window#waybar.hidden { #clock { font-family: JetBrainsMono Nerd Font; - color: @mauve; + color: @green; + border-bottom: 3px solid @green; } tooltip { diff --git a/waybar/style.css-without-borders b/waybar/style.css-without-borders deleted file mode 100644 index c3d8dca..0000000 --- a/waybar/style.css-without-borders +++ /dev/null @@ -1,157 +0,0 @@ - -/* ~/.config/waybar/style.css */ -@import "./catppuccin-waybar/themes/mocha.css"; - -* { - border: none; - border-radius: 0; - min-height: 0; - font-family: JetBrainsMono Nerd Font; - font-size: 13px; -} - -window#waybar { - background-color: alpha(@base, 0.6); - margin: 10px; - transition-property: background-color; - transition-duration: 0.5s; - color: @text; -} - -window#waybar.hidden { - opacity: 0.5; -} - -#workspaces { -} - -#workspaces button { - all: initial; - /* Remove GTK theme values (waybar #1351) */ - min-width: 0; - /* Fix weird spacing in materia (waybar #450) */ - box-shadow: inset 0 -3px transparent; - /* Use box-shadow instead of border so the text isn't offset */ - padding: 6px 18px; - margin: 6px 3px; - border-radius: 3px; - background-color: alpha(@base, 0.9); - color: @text; -} - -#workspaces button.active { - border-bottom: 3px solid @green; -} - -#workspaces button:hover { - box-shadow: inherit; - text-shadow: inherit; - background-color: @teal; - color: @base; -} - -#workspaces button.urgent { - border-bottom: 3px solid @red; -} - -#memory, -#cpu, -#custom-power, -#custom-tlp, -#battery, -#backlight, -#wireplumber, -#network, -#clock, -#tray { - border-radius: 4px; - margin: 6px 3px; - padding: 6px 12px; - background-color: @base; - color: @text; -} - -#custom-power { - color: @red; - padding: 6px 12px 6px 10px; -} - -#custom-tlp { - padding: 0 10px; - padding-right: 10px; - margin-right: 0; -} - -#custom-tlp.ac { - color: @green; /* Catppuccin Green for AC power */ -} - -#custom-tlp.bat { - color: @yellow; /* Catppuccin Yellow for Battery power */ -} - -#battery { - color: @text; - padding: 0 10px; - padding-left: 0; - margin-left: 0; -} - -#battery.charging, #battery.plugged { - color: @green; -} - -#battery.warning { - color: @yellow; -} - -#battery.critical { - color: @red; - animation-name: blink; - animation-duration: 0.8s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; -} - -@keyframes blink { - to { - color: @text; - } -} - -#memory, -#cpu { - color: @maroon; -} - - -#backlight { - color: @mauve; -} - -#wireplumber { - color: @mauve; - padding-right: 15px; -} - -#network { - color: @mauve; - padding-right: 15px; -} - -#clock { - font-family: JetBrainsMono Nerd Font; - color: @mauve; -} - -tooltip { - border-radius: 8px; - padding: 15px; - background-color: @base; -} - -tooltip label { - padding: 5px; - background-color: @base; -} diff --git a/waybar/style.css.bak b/waybar/style.css.bak deleted file mode 100644 index f5a09ce..0000000 --- a/waybar/style.css.bak +++ /dev/null @@ -1,81 +0,0 @@ -/* ~/.config/waybar/style.css */ -@import "./catppuccin-waybar/themes/mocha.css"; - -* { - font-family: "0xProto Nerd Font", FontAwesome, sans-serif; - font-size: 14px; - padding: 0 5px; -} - -window#waybar { - background-color: alpha(@base, 0.9); - border-bottom: 3px solid @mauve; - color: @text; -} - -#workspaces { - margin-bottom: 5px; -} - -#workspaces button { - padding: 0 5px; - background-color: transparent; - color: @surface2; -} - -#workspaces button.active { - color: @mauve; - border-bottom: 3px solid @pink; -} - -#workspaces button:hover { - background: @surface0; - box-shadow: inherit; - text-shadow: inherit; -} - -#custom-power { - color: @red; - padding: 0 10px; -} - -#custom-tlp { - padding: 0 10px; -} - -#custom-tlp.ac { - color: @green; /* Catppuccin Green for AC power */ -} - -#custom-tlp.bat { - color: @yellow; /* Catppuccin Yellow for Battery power */ -} - -#battery { - color: @text; - padding: 0 10px; - padding-left: 0; -} - -#battery.charging, #battery.plugged { - color: @green; -} - -#battery.warning { - color: @yellow; -} - -#battery.critical { - color: @red; - animation-name: blink; - animation-duration: 0.8s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; -} - -@keyframes blink { - to { - color: @text; - } -}