feat(waybar): improve screen recorder module

This commit is contained in:
2025-09-18 11:13:53 +02:00
parent e9b92fcd3c
commit 4df06b6d77
5 changed files with 55 additions and 21 deletions

View File

@@ -1,5 +1,9 @@
#! /usr/bin/env bash #! /usr/bin/env bash
toggle_screenrecording() {
pkill -RTMIN+8 waybar
}
main() { main() {
pid="$(pgrep "wf-recorder" || pgrep "slurp")" pid="$(pgrep "wf-recorder" || pgrep "slurp")"
status=$? status=$?
@@ -17,10 +21,14 @@ main() {
fi fi
filename="$output_dir/$(date +'recording_%Y-%m-%d-%H%M%S.mp4')" filename="$output_dir/$(date +'recording_%Y-%m-%d-%H%M%S.mp4')"
region="$(slurp)"
region="$(slurp)" && wf-recorder -g "$region" -f "$filename" wf-recorder -g "$region" -f "$filename" &
toggle_screenrecording
else else
pkill --signal SIGINT wf-recorder pkill --signal SIGINT wf-recorder
toggle_screenrecording
fi fi
} }

View File

@@ -9,7 +9,6 @@
"modules-center": ["clock"], "modules-center": ["clock"],
"modules-right": [ "modules-right": [
"custom/pacman", "custom/pacman",
"custom/recorder",
"privacy", "privacy",
"group/system", "group/system",
"group/misc", "group/misc",
@@ -21,7 +20,13 @@
}, },
"group/misc": { "group/misc": {
"orientation": "inherit", "orientation": "inherit",
"modules": ["pulseaudio", "pulseaudio#microphone", "backlight", "battery"] "modules": [
"pulseaudio",
"pulseaudio#microphone",
"backlight",
"battery",
"custom/recorder"
]
}, },
"group/connections": { "group/connections": {
"orientation": "inherit", "orientation": "inherit",
@@ -89,13 +94,10 @@
"signal": 1 "signal": 1
}, },
"custom/recorder": { "custom/recorder": {
"interval": 1,
"tooltip": true,
"format": "",
"return-type": "json", "return-type": "json",
"exec": "echo '{\"class\": \"recording\"}'", "exec": "$HOME/.config/waybar/scripts/check-screen-recorder.sh",
"exec-if": "pgrep wf-recorder", "on-click": "$HOME/.config/sway/scripts/screen-recorder.sh",
"on-click": "$HOME/.config/sway/scripts/screen-recorder.sh" "signal": 8
}, },
"privacy": { "privacy": {
"icon-spacing": 4, "icon-spacing": 4,

View File

@@ -9,7 +9,6 @@
"modules-center": ["clock"], "modules-center": ["clock"],
"modules-right": [ "modules-right": [
"custom/pacman", "custom/pacman",
"custom/recorder",
"privacy", "privacy",
"group/system", "group/system",
"group/misc", "group/misc",
@@ -21,7 +20,13 @@
}, },
"group/misc": { "group/misc": {
"orientation": "inherit", "orientation": "inherit",
"modules": ["pulseaudio", "pulseaudio#microphone", "backlight", "battery"] "modules": [
"pulseaudio",
"pulseaudio#microphone",
"backlight",
"battery",
"custom/recorder"
]
}, },
"group/connections": { "group/connections": {
"orientation": "inherit", "orientation": "inherit",
@@ -83,13 +88,10 @@
"signal": 1 "signal": 1
}, },
"custom/recorder": { "custom/recorder": {
"interval": 1,
"tooltip": true,
"format": "",
"return-type": "json", "return-type": "json",
"exec": "echo '{\"class\": \"recording\"}'", "exec": "$HOME/.config/waybar/scripts/check-screen-recorder.sh",
"exec-if": "pgrep wf-recorder", "on-click": "$HOME/.config/sway/scripts/screen-recorder.sh",
"on-click": "$HOME/.config/sway/scripts/screen-recorder.sh" "signal": 8
}, },
"privacy": { "privacy": {
"icon-spacing": 4, "icon-spacing": 4,

View File

@@ -0,0 +1,15 @@
#! /usr/bin/env bash
main() {
local data=""
if pgrep -x wf-recorder > /dev/null 2>&1; then
data='{"text": "󰻂", "tooltip": "Stop recording", "class": "active"}'
else
data='{"text": "󰻂", "tooltip": "Start recording", "class": "idle"}'
fi
echo $data | jq --unbuffered --compact-output
}
main $@

View File

@@ -46,7 +46,6 @@ tooltip label {
#mode, #mode,
#clock, #clock,
#workspaces, #workspaces,
#custom-recorder,
#custom-power, #custom-power,
#mpris, #mpris,
#mpris.paused, #mpris.paused,
@@ -56,7 +55,7 @@ tooltip label {
color: #ffffff; color: #ffffff;
} }
#custom-recorder, #custom-pacman { #custom-pacman {
background-color: #32e47c; background-color: #32e47c;
color: #383c4a; color: #383c4a;
} }
@@ -103,7 +102,6 @@ tooltip label {
} }
#custom-pacman, #custom-pacman,
#custom-recorder,
#mode, #mode,
#mpris, #mpris,
#custom-power, #custom-power,
@@ -112,7 +110,6 @@ tooltip label {
} }
#custom-pacman, #custom-pacman,
#custom-recorder,
#mode, #mode,
#clock, #clock,
#privacy, #privacy,
@@ -164,3 +161,13 @@ tooltip label {
#idle_inhibitor.activated { #idle_inhibitor.activated {
background-color: #26a65b; background-color: #26a65b;
} }
#custom-recorder {
padding-top: 4px;
padding-bottom: 4px;
padding-left: 8px;
}
#custom-recorder.active {
color: #e63946;
}