-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsxhkdctl
More file actions
executable file
·61 lines (54 loc) · 2.2 KB
/
sxhkdctl
File metadata and controls
executable file
·61 lines (54 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: sxhkdctl
# Created: Sunday, 2020/04/19 - 21:54:57
# Author: Fabiano Matos (none) - [fgm@note]
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:41:05
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.2.4.122
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# Thursday, 2022/01/27 - 14:22:53: (fgm)
# -> refactor with ~/bin/lib/init
source "$xSHELL_INIT"
use args
xrequirements sxhkd datesh puts
lockfile=/tmp/$APP.lock
trap "[ -f $lockfile ] && /bin/rm -f $lockfile && exit 1" 2 3 13 15
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
run_daemon(){
# check if this script already running
if [ ! -f $lockfile ]; then
echo "$(datesh)-$USER@$(hostname):$APP" > $lockfile
while true; do
if ! pgrep -x sxhkd ; then
# not runnung start daemon
sxhkd &
fi
# check if is discharging (not conected to powerline)
discharging=$(acpi | grep Discharging)
if [ "$discharging" != "" ]; then
# check battery capacity
bat=$(acpi | cut -d ',' -f2 | tr -d '%' | tr -d ' ')
case 1 in
$(($bat<=30))) notify-send -u critical "Low Battery" "$bat %" ;;
esac
fi
# check every 30 seconds
sleep 30
done
else
puts c "$APP already running"
fi
}
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
xarg --id -d,--daemon --code "run_daemon &" --desc "watch if 'sxhkd' is running. start new instance if not"
xrun --require-one "$@"