-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Hyde-tool
executable file
·119 lines (109 loc) · 4.35 KB
/
Hyde-tool
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/env bash
export CLI_PATH=$(dirname $(dirname ${0}))
export PATH=$PATH:${CLI_PATH}/lib/hyde-cli/
hyde_cli_version=$(cat ${CLI_PATH}/share/hyde-cli/.hyde-cli.ver | head -1)
. DEVEL-hyde
. FUNCTIONS-hyde
#? Handle Syntax errors
if [ -z "$1" ]; then
. GLOBAL-hyde
box_me -s "Hyde-cli $hyde_cli_version"
print_prompt "$(main_help_content)"
exit 1
elif ! (awk '{print $1}' <<< "$(main_help_content)" | grep -q "$1" ); then
. GLOBAL-hyde
print_prompt -crit "[unknown]: " -y "$*" "\nUsage: Hyde [Function] [Arguments] [Parameter]\n"
print_prompt "$(main_help_content)"
exit 1
fi
#! DO NOT USE ANY BASH FORMATTER HERE that NUKES some ';' symbols
#! +----------------------------------------------------------------|
#? Add functions below this section
#? Be careful with spaces in your Function definitions
#? Example Function:
#* |Function example() { #? Example Function. this comments supports '\n'
#? | ^^^^ Use use as description and respects
#* | case $1 in
#* | # Cases go here...
#* | case1) #? Case description
#? | ^^^ description for case functions
#* | #* | commands...
#* | : <<USAGE
#* | [FUNCTION_CASE_USAGE ]
#* | --flags ? Description for flags
#* | --args ? Desc for args
#* | --parms ? desc for param
#* | [END]
#* | USAGE
#? | ^^^^^^ Usage block is a comment block that will be parsed by gen_completion and man function
#* | ;;
#* |
#* | esac; <== ' ; ' is also use to parse case conditions
#* |}
#! +----------------------------------------------------------------|
man() { #? Show Manual
. FUNCTIONS-hyde
. GLOBAL-hyde
. "${META_FILE}" 2>/dev/null || print_prompt -r "Looks like you did not run 'Hyde-install'! "
[ -f "$HYDE_RUNTIME_DIR/Hyde_man" ] && [[ $* == *"--reload"* ]] && rm "$HYDE_RUNTIME_DIR/Hyde_man"
if [ -f "$HYDE_RUNTIME_DIR/Hyde_man" ] ; then
local man_ver="$(grep "Hyde-cli Version:" "$HYDE_RUNTIME_DIR/Hyde_man" | cut -d ":" -f2)"
if grep -q "${man_ver}" <<< "${hyde_cli_version}"; then
cat "$HYDE_RUNTIME_DIR/Hyde_man"
exit
else
echo "Updating man page..."
print_prompt -g "[update] " "updating man page to ${man_ver}..."
fi
fi
manPage=$(
echo -e "Hyde-cli ${hyde_cli_version}"
[ -d "${CloneDir}" ] && echo "Hyde Clone Directory: ${CloneDir}"
echo -e "Usage: Hyde-tool [Function] [options]\n"
grep -E '^\w+ *\( *\)\s*\{ #\?' $0 | while read -r line; do
Function=$(echo "$line" | awk 'BEGIN { FS = "[()#?]" } { print $1 }')
desc=$(echo "$line" | awk 'BEGIN { FS = "[()#?]" } { gsub(/\\n/, "\\n\t\t\t", $5); print $5 }')
printf " \n%-45s %s\n\n" "$(print_prompt -y "[" "${Function}" -y "]")" "$(print_prompt -c "" "${desc}")"
Parameters "${Function}"
done
)
(
[ "${clean_man}" = true ] || box_me -c 220 "Tools Manual Page"
echo -e "${manPage}" |
sed -e "s|\${CloneDir}|$CloneDir|g" \
-e "s|\${HOME}|${HOME}|g" \
-e "s|\${hydeConfDir}|${hydeConfDir}|g" \
-e "s|\${ctlFile}|$ctlFile|g"
barLine
print_prompt "\nDescriptions with" -y " [*]" " can be expanded to show more information. Append [--help]"
print_prompt "\nRegenerate this 'man' page by appending '--reload' flag. 'Hyde-tool man --reload' "
) | cat - 2>/dev/null | tee "$HYDE_RUNTIME_DIR/Hyde_man"
}
zoom() { #? Zoom in/out Hyprland
# case
intensity=${2:-0.1}
case $1 in
in) #? Zoom in
hyprctl keyword cursor:no_hardware_cursors 1
hyprctl keyword cursor:zoom_factor $(hyprctl getoption cursor:zoom_factor -j | jq --arg zoomFactor "$intensity" '.float + ($zoomFactor | tonumber)')
;;
out) #? Zoom out
hyprctl keyword cursor:no_hardware_cursors 1
hyprctl keyword cursor:zoom_factor "$(\
hyprctl getoption cursor:zoom_factor -j | jq --arg zoomFactor "$intensity" '
if (.float - ($zoomFactor | tonumber)) < 1 then 1 else (.float - ($zoomFactor | tonumber)) end'\
)"
;;
reset) #? Reset Zoom
hyprctl keyword cursor:zoom_factor 1
;;
*)
. GLOBAL-hyde
. FUNCTIONS-hyde
Parameters "${FUNCNAME[0]}" ;;
esac;
}
[ -z "${1}" ] && $0 man | cat && exit 0
#! +----------------------------------------------------------------|
"${@}" #? Call the appropriate Function based on the first argument. |
#! +----------------------------------------------------------------|