Refresh clock on the minute instead of every 10 seconds.
parent
a2bdb93d5e
commit
5fa7f918a1
@ -0,0 +1,2 @@
|
||||
# Do not power devices that have no driver attached.
|
||||
hw.pci.do_power_nodriver=3
|
@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Report screen recording status in FreeBSD
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
SLEEP_INTERVAL=${SLEEP_INTERVAL:-10}
|
||||
DELAY_ACTION=${DELAY_ACTION:-2}
|
||||
|
||||
function main {
|
||||
local previous_reported="-1"
|
||||
local now=$(date +%s)
|
||||
local check_again_at=$((now + SLEEP_INTERVAL))
|
||||
local next_sleep_interval=$SLEEP_INTERVAL
|
||||
|
||||
stream_key_binding_activations | while true; do
|
||||
if read -t "$next_sleep_interval" event; then
|
||||
now=$(date +%s)
|
||||
latest_allowed_check=$((now + DELAY_ACTION))
|
||||
if [ "$latest_allowed_check" -lt "$check_again_at" ]; then
|
||||
# Scheduling a debounced action
|
||||
check_again_at=$latest_allowed_check
|
||||
next_sleep_interval=$DELAY_ACTION
|
||||
else
|
||||
# New debounced event would trigger after a check is already scheduled
|
||||
next_sleep_interval=$((check_again_at - now))
|
||||
fi
|
||||
if [ "$now" -lt "$check_again_at" ]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
if pgrep -q wl-screenrec; then
|
||||
local is_running=1
|
||||
else
|
||||
local is_running=0
|
||||
fi
|
||||
if [ "$is_running" -ne "$previous_reported" ]; then
|
||||
previous_reported="$is_running"
|
||||
report "$is_running"
|
||||
fi
|
||||
|
||||
now=$(date +%s)
|
||||
check_again_at=$((now + SLEEP_INTERVAL))
|
||||
next_sleep_interval=$SLEEP_INTERVAL
|
||||
done
|
||||
}
|
||||
|
||||
function stream_key_binding_activations {
|
||||
echo "{}"
|
||||
swaymsg --raw --monitor --type subscribe '[ "binding" ]'
|
||||
}
|
||||
|
||||
function report {
|
||||
is_running="$1"
|
||||
if [ "$is_running" -eq 0 ]; then
|
||||
jq --unbuffered --compact-output <<EOF
|
||||
{
|
||||
"text":"",
|
||||
"tooltip":"Not recording",
|
||||
"percentage":0,
|
||||
"class":"hidden"
|
||||
}
|
||||
EOF
|
||||
else
|
||||
jq --unbuffered --compact-output <<EOF
|
||||
{
|
||||
"text":"⏺",
|
||||
"tooltip":"Recording",
|
||||
"percentage":100,
|
||||
"class":"visible"
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
Loading…
Reference in New Issue