-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpukill
More file actions
executable file
·49 lines (42 loc) · 1.23 KB
/
cpukill
File metadata and controls
executable file
·49 lines (42 loc) · 1.23 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
#!/usr/bin/env bash
function cpulook/initialize-cpudir {
unset -f "$FUNCNAME"
local script=$0
if [[ -h $script ]]; then
local path=$(realpath "$0" || readlink -f "$0" || /bin/readlink -f "$script") 2>/dev/null
[[ $path ]] && script=$path
fi
[[ $script =~ ^(/?)(.*/)[^/]*$ ]]
local script_dir=${BASH_REMATCH[1]:-$PWD/}${BASH_REMATCH[2]}
script_dir=${script_dir%/}
if [[ -d ${script_dir:-/} ]]; then
cpudir=$script_dir
elif local dir=${XDG_DATA_HOME:-$HOME/.local/share}/cpulook; [[ -d $dir ]]; then
cpudir=$dir
else
cpudir=$script_dir
fi
# Go to the parent directory until we find $cpudir/lib/cpudef.bash
while
local common=$cpudir/lib/cpudef.bash
if [[ -f $common ]]; then
if [[ ! -r $common ]]; then
printf '%s\n' "$script: permission denied for the cpulook directory." >&2
return 1
fi
source "$common"
return "$?"
fi
[[ $cpudir == */* ]]
do
cpudir=${cpudir%/*}
done
cpudir=
printf '%s\n' "$script: failed to detect the cpulook directory." >&2
return 1
}
cpulook/initialize-cpudir || exit "$?"
##----CPULOOK_COMMON_HEADER_END----
source "$cpudir/lib/echox.bash"
source "$cpudir/m/switch"
cpulook/system:"$cpulook_system"/kill "$@"