62 lines
1.4 KiB
Bash
62 lines
1.4 KiB
Bash
bt() {
|
|
(( ${+commands[bluetoothctl]} )) || return 2
|
|
|
|
if [[ $1 == on ]]; then
|
|
(( ${+commands[connmanctl]} )) &&
|
|
connmanctl enable bluetooth ||
|
|
bluetoothctl power on
|
|
elif [[ $1 == off ]]; then
|
|
(( ${+commands[connmanctl]} )) &&
|
|
connmanctl disable bluetooth ||
|
|
bluetoothctl power off
|
|
else
|
|
bluetoothctl "$@"
|
|
fi
|
|
}
|
|
|
|
doasedit() {
|
|
(( ${+commands[doas]} )) || return 2
|
|
[[ $# -eq 0 ]] || return 1
|
|
|
|
doas -L
|
|
doas -u root sh -c "cp /etc/doas.conf /tmp/doas.conf &&
|
|
rvim -n /tmp/doas.conf &&
|
|
doas -C /tmp/doas.conf &&
|
|
mv /tmp/doas.conf /etc/doas.conf &&
|
|
echo 'ok' ||
|
|
echo >&2 'error'"
|
|
local STATUS=$?
|
|
doas -L
|
|
|
|
return $STATUS
|
|
}
|
|
|
|
get_ip() {
|
|
(( ${+commands[curl]} )) || return 2
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
[[ $1 == --ip ]] && local IP="?ip=$2" && shift || local ARGS+=("$1")
|
|
shift
|
|
done
|
|
|
|
(( ${+commands[jq]} )) && local JQ="| jq"
|
|
eval "curl ${ARGS[@]} -fsSL 'https://ifconfig.co/json$IP' $JQ"
|
|
}
|
|
|
|
http() {
|
|
(( ${+commands[python]} )) || return 2
|
|
|
|
[[ $# -gt 0 ]] && local DIR="--directory=$1" && shift
|
|
eval "python -m http.server 8080 --bind 127.0.0.1 $DIR $@"
|
|
}
|
|
|
|
open() {
|
|
if [[ $# -gt 1 ]] && (( ${+commands[$1]} )); then
|
|
nohup "$@" &> /dev/null & disown
|
|
else
|
|
(( ${+commands[xdg-open]} )) || return 2
|
|
nohup xdg-open "$@" &> /dev/null & disown
|
|
fi
|
|
}
|
|
|