revamp run sh
This commit is contained in:
parent
56b3f093db
commit
14263c00b2
@ -112,7 +112,4 @@ passwd <username>
|
|||||||
23. login, `sudo su`
|
23. login, `sudo su`
|
||||||
24. Uncomment locale in `/etc/locale.gen`, run `locale-gen`
|
24. Uncomment locale in `/etc/locale.gen`, run `locale-gen`
|
||||||
25. `echo "<name>" > /etc/hostname`
|
25. `echo "<name>" > /etc/hostname`
|
||||||
26. `systemctl enable NetworkManager --now`
|
26. Get tz from `tzselect`, set via `timedatectl set-timezone [tz]`
|
||||||
27. Enable and sync time: `systemctl enable systemd-timesyncd --now`
|
|
||||||
28. Get tz from `tzselect`, set via `timedatectl set-timezone [tz]`
|
|
||||||
29. Update hwclock: `hwclock -w --utc`
|
|
||||||
|
19
arch-user/bin/bemenu/run-calc.sh
Executable file
19
arch-user/bin/bemenu/run-calc.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
shift
|
||||||
|
query="$1"
|
||||||
|
if [ -z "$query" ]; then
|
||||||
|
query="$(echo "tui" | bemenu --prompt "qalc")"
|
||||||
|
fi
|
||||||
|
if [ "$query" = "tui" ]; then
|
||||||
|
exec footclient --app-id="footclient_float" -D ~/ "qalc";
|
||||||
|
elif [ -n "$query" ]; then
|
||||||
|
qalc_res="$(qalc --terse "$query")"
|
||||||
|
menu_res="$(echo -e "$qalc_res\ntui" | bemenu --prompt "qalc")"
|
||||||
|
if [ "$qalc_res" = "$menu_res" ]; then
|
||||||
|
wl-copy "$qalc_res"
|
||||||
|
notify-send "$qalc_res" -a calc "Result copied to clipboard"
|
||||||
|
elif [ -n "$menu_res" ]; then
|
||||||
|
"$0" _ "$menu_res"
|
||||||
|
fi
|
||||||
|
fi
|
21
arch-user/bin/bemenu/run-capture.sh
Executable file
21
arch-user/bin/bemenu/run-capture.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$*" = "screenshot output" ]; then
|
||||||
|
mon="$(swaymsg -t get_outputs | jq -r '. | map(select(.focused == true)) | .[0].name')"
|
||||||
|
outfile="screenshot-$(date +%s).png"
|
||||||
|
grim -o "$mon" - | tee ~/tmp/"$outfile" | wl-copy -t image/png
|
||||||
|
notify-send Done -a screenshot "Saved to tmp/$outfile\nCopied to clipboard"
|
||||||
|
elif [ "$*" = "screenshot selection" ]; then
|
||||||
|
outfile="screenshot-$(date +%s).png"
|
||||||
|
grim -g "$(slurp)" - | tee ~/tmp/"$outfile" | wl-copy -t image/png
|
||||||
|
notify-send Done -a screenshot "Saved to tmp/$outfile\nCopied to clipboard"
|
||||||
|
elif [ "$*" = "pick-color" ]; then
|
||||||
|
hex="$(
|
||||||
|
grim -g "$(slurp -p)" -t ppm - | \
|
||||||
|
magick - -format '%[pixel:p{0,0}]' txt:- | \
|
||||||
|
tail -n 1 | \
|
||||||
|
cut -d ' ' -f 4
|
||||||
|
)"
|
||||||
|
echo -n "$hex" | wl-copy
|
||||||
|
notify-send "$hex" -a screenshot "Color code copied to clipboard"
|
||||||
|
fi
|
12
arch-user/bin/bemenu/run-man.sh
Executable file
12
arch-user/bin/bemenu/run-man.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
shift
|
||||||
|
page="$1"
|
||||||
|
if [ -z "$page" ]; then
|
||||||
|
page="$(
|
||||||
|
man -k . | \
|
||||||
|
(bemenu --prompt "man" || exec ~/.local/bin/bemenu/run.sh) | \
|
||||||
|
sed ' s/\s\+\-.*//;s/ //g'
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
exec footclient --app-id="footclient_float" "$SHELL" -c "man '$page' || read -n1"
|
15
arch-user/bin/bemenu/run-pass.sh
Executable file
15
arch-user/bin/bemenu/run-pass.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
type="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
cd "$PASSWORD_STORE_DIR"
|
||||||
|
pws="$(find -path "*/.*" -prune -o -path "*/cred/*" -name "*.gpg" -printf '%P\n' | sed 's/\.gpg$//')"
|
||||||
|
pw="$(echo "$pws" | bemenu --prompt "pass")"
|
||||||
|
|
||||||
|
case "$type" in
|
||||||
|
otp) pass otp -c "$pw" && notify-send "$pw" -a pass "OTP copied to clipboard, clears in 45s";;
|
||||||
|
*) pass -c "$pw" && notify-send "$pw" -a pass "Password copied to clipboard, clears in 45s";;
|
||||||
|
esac
|
||||||
|
|
10
arch-user/bin/bemenu/run-power.sh
Executable file
10
arch-user/bin/bemenu/run-power.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sure() {
|
||||||
|
echo yes | bemenu --prompt "sure?" || exec ~/.local/bin/bemenu/run.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
poweroff|reboot|suspend) sure && systemctl "$@";;
|
||||||
|
logout) sure && swaymsg exit;;
|
||||||
|
esac
|
@ -1,211 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
LIST=();
|
rl_full="$(cat "$HOME/.config/bemenu/"*.runlist)"
|
||||||
# gui
|
rl="$(echo "$rl_full" | cut -d' ' -f2-)"
|
||||||
if [ "$USER" = "yrzam" ]; then
|
|
||||||
LIST+=(
|
|
||||||
"web" "web projects"
|
|
||||||
"web" "web life"
|
|
||||||
)
|
|
||||||
WEB_HAS_PROFILES=1
|
|
||||||
else
|
|
||||||
LIST+=(
|
|
||||||
"web" "web"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
LIST+=(
|
|
||||||
"gui" "telegram-desktop"
|
|
||||||
"gui" "gimp"
|
|
||||||
"gui" "sqlitebrowser"
|
|
||||||
# tui
|
|
||||||
"shell_tui" "vifm"
|
|
||||||
"shell_tui" "vim"
|
|
||||||
"tui" "htop"
|
|
||||||
"float_tui" "nmtui"
|
|
||||||
"float_tui" "bluetoothctl"
|
|
||||||
"man" "man"
|
|
||||||
"float_tui" "node"
|
|
||||||
"term" "term"
|
|
||||||
# native
|
|
||||||
"screen_pick" "screenshot output"
|
|
||||||
"screen_pick" "screenshot selection"
|
|
||||||
"screen_pick" "color-picker"
|
|
||||||
"todo" "pass"
|
|
||||||
"calc" "calc"
|
|
||||||
"todo" "translate ru-en"
|
|
||||||
"todo" "translate en-ru"
|
|
||||||
"grep_dict" "dict"
|
|
||||||
)
|
|
||||||
if [ "$FEAT_BRIGHTNESS" ]; then
|
|
||||||
LIST+=(
|
|
||||||
"brightness" "brightness"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
LIST+=(
|
|
||||||
"direct" "sway reload"
|
|
||||||
"power" "logout"
|
|
||||||
"todo" "inhibit"
|
|
||||||
"power" "suspend"
|
|
||||||
"power" "poweroff"
|
|
||||||
"power" "poweroff --check-inhibitors=no"
|
|
||||||
"power" "reboot"
|
|
||||||
)
|
|
||||||
|
|
||||||
sure() {
|
inp="$(echo "$rl" | bemenu --prompt ">")"
|
||||||
echo yes | bemenu --prompt "sure?"
|
eval "inp_arr=($inp)"
|
||||||
}
|
exectr=float-sh-keep
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ "$inp" == "$line"* ]]; then
|
||||||
|
exectr="$(echo "$rl_full" | grep -F "$line" -m 1 | cut -d' ' -f1)"
|
||||||
|
fi
|
||||||
|
done <<< "$rl"
|
||||||
|
|
||||||
# generic
|
case "$exectr" in
|
||||||
exec_gui() {
|
exec) exec $inp;;
|
||||||
exec "$@"
|
float-sh) exec footclient --app-id="footclient_float" -D ~/ "$SHELL" -c "($inp)";;
|
||||||
}
|
float-sh-keep) exec footclient --app-id="footclient_float" -D ~/ "$SHELL" -c "($inp); read -n1";;
|
||||||
exec_tui() {
|
*) exec bash "$HOME/.local/bin/bemenu/run-$exectr.sh" "${inp_arr[@]}";;
|
||||||
exec footclient -D ~/ "$@"
|
|
||||||
}
|
|
||||||
exec_float_tui() { # todo
|
|
||||||
exec footclient --app-id="footclient_float" -D ~/ "$@"
|
|
||||||
}
|
|
||||||
exec_shell_tui() {
|
|
||||||
exec footclient -D ~/ "$SHELL" -c "$@"
|
|
||||||
}
|
|
||||||
exec_shell_full() {
|
|
||||||
exec footclient -D ~/ "$SHELL" -c "($1); read -n1"
|
|
||||||
}
|
|
||||||
exec_direct() {
|
|
||||||
exec "$@"
|
|
||||||
}
|
|
||||||
exec_term() {
|
|
||||||
exec footclient -D ~/
|
|
||||||
}
|
|
||||||
# custom
|
|
||||||
exec_web() {
|
|
||||||
shift
|
|
||||||
if [ "$WEB_HAS_PROFILES" ]; then
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
qutebrowser "$*"
|
|
||||||
}
|
|
||||||
exec_man() {
|
|
||||||
shift
|
|
||||||
page="$1"
|
|
||||||
if [ -z "$page" ]; then
|
|
||||||
page="$(
|
|
||||||
man -k . | \
|
|
||||||
bemenu --prompt "man" | \
|
|
||||||
sed ' s/\s\+\-.*//;s/ //g'
|
|
||||||
)"
|
|
||||||
fi
|
|
||||||
[ -n "$page" ] && exec footclient "$SHELL" -c "man '$page' || read -n1"
|
|
||||||
}
|
|
||||||
exec_screen_pick() {
|
|
||||||
if [ "$*" = "screenshot output" ]; then
|
|
||||||
mon="$(swaymsg -t get_outputs | jq -r '. | map(select(.focused == true)) | .[0].name')"
|
|
||||||
grim -o "$mon" - | wl-copy -t image/png
|
|
||||||
notify-send Done -a screenshot "PNG image copied to clipboard" -t 3000
|
|
||||||
elif [ "$*" = "screenshot selection" ]; then
|
|
||||||
grim -g "$(slurp)" - | wl-copy -t image/png
|
|
||||||
notify-send Done -a screenshot "PNG image copied to clipboard" -t 3000
|
|
||||||
elif [ "$*" = "color-picker" ]; then
|
|
||||||
hex="$(
|
|
||||||
grim -g "$(slurp -p)" -t ppm - | \
|
|
||||||
magick - -format '%[pixel:p{0,0}]' txt:- | \
|
|
||||||
tail -n 1 | \
|
|
||||||
cut -d ' ' -f 4
|
|
||||||
)"
|
|
||||||
notify-send "$hex" -a screenshot "stnrit" -t 3000
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
exec_pass() {
|
|
||||||
echo 1
|
|
||||||
}
|
|
||||||
exec_calc() {
|
|
||||||
shift
|
|
||||||
query="$1"
|
|
||||||
if [ -z "$query" ]; then
|
|
||||||
query="$(echo "tui" | bemenu --prompt "qalc")"
|
|
||||||
fi
|
|
||||||
if [ "$query" = "tui" ]; then
|
|
||||||
exec_float_tui "qalc"
|
|
||||||
elif [ -n "$query" ]; then
|
|
||||||
qalc_res="$(qalc --terse "$query")"
|
|
||||||
menu_res="$(echo -e "$qalc_res\ntui" | bemenu --prompt "qalc")"
|
|
||||||
if [ "$qalc_res" = "$menu_res" ]; then
|
|
||||||
wl-copy "$qalc_res"
|
|
||||||
notify-send "$qalc_res" -a calc "Result copied to clipboard" -t 3000
|
|
||||||
elif [ -n "$menu_res" ]; then
|
|
||||||
exec_calc _ "$menu_res"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
exec_transl() {
|
|
||||||
echo 1
|
|
||||||
}
|
|
||||||
exec_grep_dict() {
|
|
||||||
shift
|
|
||||||
dict="$1"
|
|
||||||
pattern="$2"
|
|
||||||
dicts_path="$HOME/know/dict/"
|
|
||||||
if [ -z "$dict" ]; then
|
|
||||||
dict="$(find "$dicts_path" -type f -printf "%f\n" | bemenu --prompt "dict")"
|
|
||||||
[ -z "$dict" ] && return
|
|
||||||
fi
|
|
||||||
if [ -z "$pattern" ]; then
|
|
||||||
pattern="$(echo -n | bemenu --prompt "grep $dict")"
|
|
||||||
[ -z "$pattern" ] && return
|
|
||||||
fi
|
|
||||||
res="$({ echo ..; grep "$pattern" "$dicts_path/$dict"; } | bemenu --prompt " ")"
|
|
||||||
if [ "$res" = ".." ]; then
|
|
||||||
exec_grep_dict _ "$dict"
|
|
||||||
else
|
|
||||||
wl-copy "$res"
|
|
||||||
notify-send "$res" -a dict "Word copied to clipboard" -t 3000
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
exec_brightness() {
|
|
||||||
shift
|
|
||||||
target="$1"
|
|
||||||
if [ -z "$target" ]; then
|
|
||||||
current="$(($(brightnessctl g)*100/$(brightnessctl m)))"
|
|
||||||
current_i="$((current/5))"
|
|
||||||
list="$(echo 1%; seq 5 5 100 | sed 's/$/%/')";
|
|
||||||
target="$(echo "$list" | bemenu --index $current_i --prompt "$current% ->")";
|
|
||||||
fi
|
|
||||||
if [ -n "$target" ] && [ "$target" != "$current%" ]; then
|
|
||||||
brightnessctl set "$target"
|
|
||||||
[ -z "$1" ] && exec_brightness _
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
exec_power() {
|
|
||||||
case "$1" in
|
|
||||||
poweroff|reboot|suspend) sure && systemctl "$@";;
|
|
||||||
logout) sure && swaymsg exit;;
|
|
||||||
esac
|
esac
|
||||||
}
|
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
out="$*";
|
|
||||||
else
|
|
||||||
out=$(
|
|
||||||
for (( i=1; i<${#LIST[@]}; i+=2 )); do
|
|
||||||
echo "${LIST[$i]}";
|
|
||||||
done | bemenu --prompt ">"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$out" ]; then
|
|
||||||
for (( i=1; i<${#LIST[@]}; i+=2 )); do
|
|
||||||
if [[ "$out" == "${LIST[$i]}"* ]]; then
|
|
||||||
executor=${LIST[$((i-1))]}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
[ -z "$executor" ] && executor=shell_full
|
|
||||||
|
|
||||||
if [ "$executor" = "shell_full" ]; then
|
|
||||||
"exec_$executor" "$out"
|
|
||||||
else
|
|
||||||
eval "executor_args=($out)"
|
|
||||||
#shellcheck disable=SC2154
|
|
||||||
"exec_$executor" "${executor_args[@]}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
18
arch-user/config/bemenu/base.runlist
Normal file
18
arch-user/config/bemenu/base.runlist
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
exec qutebrowser
|
||||||
|
exec gimp
|
||||||
|
exec sqlitebrowser
|
||||||
|
exec telegram-desktop
|
||||||
|
man man
|
||||||
|
calc calc
|
||||||
|
power suspend
|
||||||
|
power poweroff
|
||||||
|
power poweroff --check-inhibitors=no
|
||||||
|
power logout
|
||||||
|
power reboot
|
||||||
|
pass pass
|
||||||
|
pass pass otp
|
||||||
|
pass pass info
|
||||||
|
capture screenshot selection
|
||||||
|
capture screenshot output
|
||||||
|
capture pick-color
|
||||||
|
float-sh nmtui
|
@ -9,3 +9,7 @@ padding=5,10
|
|||||||
width=600
|
width=600
|
||||||
progress-color=#{{ .theme.color.fg_accent }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }}
|
progress-color=#{{ .theme.color.fg_accent }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }}
|
||||||
layer=overlay
|
layer=overlay
|
||||||
|
|
||||||
|
[app-name=screenshot]
|
||||||
|
default-timeout=10000
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user