Some modifications, tailscale scripts
This commit is contained in:
45
bin/battery
45
bin/battery
@ -1,8 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
BAT=$(acpi -b | grep "Battery $1" | rg "(\d?\d\d)%" -or '$1')
|
||||
geticon() {
|
||||
local icon=
|
||||
state=$2
|
||||
if [ "$state" = "Charging" ]; then
|
||||
icon=
|
||||
else
|
||||
[ "$1" -gt 0 ] && icon=
|
||||
[ "$1" -gt 10 ] && icon=
|
||||
[ "$1" -gt 20 ] && icon=
|
||||
[ "$1" -gt 30 ] && icon=
|
||||
[ "$1" -gt 40 ] && icon=
|
||||
[ "$1" -gt 50 ] && icon=
|
||||
[ "$1" -gt 60 ] && icon=
|
||||
[ "$1" -gt 70 ] && icon=
|
||||
[ "$1" -gt 80 ] && icon=
|
||||
[ "$1" -gt 90 ] && icon=
|
||||
fi
|
||||
|
||||
echo "$icon"
|
||||
}
|
||||
|
||||
echo BAT$(($1 + 1)): $BAT
|
||||
getcolor() {
|
||||
local color='#80ff80'
|
||||
if [ "$2" = "Charging" ]; then
|
||||
color='#0080ff'
|
||||
else
|
||||
[ "$1" -lt 60 ] && color='#ffff00'
|
||||
[ "$1" -lt 30 ] && color='#ff8000'
|
||||
[ "$1" -lt 15 ] && color='#ff0000'
|
||||
fi
|
||||
|
||||
echo "$color"
|
||||
}
|
||||
|
||||
bt=$(acpi -b | grep "Battery $1")
|
||||
BAT=$(echo "$bt" | rg "(\d?\d?\d)%" -or '$1')
|
||||
STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
|
||||
ICON=$(geticon "$BAT" "$STAT")
|
||||
COLOR=$(getcolor "$BAT" "$STAT")
|
||||
|
||||
echo "$ICON" $(($1 + 1)): "$BAT"%
|
||||
echo "$ICON" "$BAT"%
|
||||
echo "$COLOR"
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
|
@ -5,7 +5,7 @@ month=$(date +%m)
|
||||
day=$(date +%d)
|
||||
folder="$HOME/docs/daily/$year"
|
||||
note="$folder/$month.$day.md"
|
||||
mkdir -p $folder
|
||||
mkdir -p "$folder"
|
||||
[ ! -f "$note" ] && echo "# $year.$month.$day" > "$note"
|
||||
|
||||
nvim $note
|
||||
nvim "$note"
|
||||
|
20
bin/rofi-tscale
Executable file
20
bin/rofi-tscale
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ~/.dotfiles/nfrc.sh
|
||||
|
||||
action=$(printf "Connect exit node\nDisconnect" | rofi -dmenu -p "Tailscale")
|
||||
|
||||
|
||||
case "$action" in
|
||||
"Connect exit node")
|
||||
echo connecting...
|
||||
endpoint=$(tailscale status | grep "exit node" | awk '{print $2}' | rofi -dmenu -p "Select exit node")
|
||||
tailscale set --exit-node="$endpoint"
|
||||
tailscale up
|
||||
;;
|
||||
"Disconnect")
|
||||
echo disconnecting...
|
||||
tailscale set --exit-node=
|
||||
tailscale up
|
||||
;;
|
||||
esac
|
32
bin/tscale
Executable file
32
bin/tscale
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ~/.dotfiles/nfrc.sh
|
||||
|
||||
which tailscale > /dev/null || {
|
||||
echo Tailscale not installed
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -z "$1" ] && {
|
||||
echo "No args"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
"u"|"up")
|
||||
endpoint=$2
|
||||
|
||||
[ -z "$endpoint" ] && {
|
||||
endpoint=$(tailscale status | grep "exit node" | awk '{print $2}' | $FMENU 'Select server')
|
||||
[ -z "$endpoint" ] && exit 1
|
||||
}
|
||||
|
||||
tailscale set --exit-node="$endpoint"
|
||||
tailscale up
|
||||
;;
|
||||
"d"|"down")
|
||||
tailscale set --exit-node=
|
||||
tailscale up
|
||||
;;
|
||||
esac
|
Reference in New Issue
Block a user