feature: style update, waybar update, funny fastfetch update and other fixes
This commit is contained in:
+96
@@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
# Checking if programms are available
|
||||
case x"$@" in
|
||||
x" Stop wireguard")
|
||||
coproc (wg-quick down wg0 >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start wireguard")
|
||||
coproc (wg-quick up wg0 >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Stop netbird")
|
||||
coproc (netbird down >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start netbird")
|
||||
coproc (netbird up >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Stop sing-box")
|
||||
coproc (sudo systemctl stop sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start sing-box")
|
||||
coproc (sudo systemctl start sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# Checking if programms are installed
|
||||
wireguard_installed=true
|
||||
if ! command -v wg-quick >/dev/null 2>&1; then
|
||||
wireguard_installed=false
|
||||
else
|
||||
wireguard_installed=true
|
||||
fi
|
||||
|
||||
netbird_installed=true
|
||||
if ! command -v netbird >/dev/null 2>&1; then
|
||||
netbird_installed=false
|
||||
else
|
||||
netbird_installed=true
|
||||
fi
|
||||
|
||||
sing_box_installed=true
|
||||
if ! systemctl list-unit-files -q sing-box.service >/dev/null 2>&1; then
|
||||
sing_box_installed=false
|
||||
else
|
||||
sing_box_installed=true
|
||||
fi
|
||||
|
||||
# active param
|
||||
active="\0active\x1f"
|
||||
|
||||
# wireguard
|
||||
if $wireguard_installed; then
|
||||
wireguard_status=$(sudo wg show interfaces)
|
||||
if [ "$wireguard_status" != "wg0" ]; then
|
||||
echo " Start wireguard"
|
||||
else
|
||||
active+="0"
|
||||
echo " Stop wireguard"
|
||||
fi
|
||||
else
|
||||
echo " Wireguard not installed"
|
||||
fi
|
||||
|
||||
# netbird
|
||||
if $netbird_installed; then
|
||||
netbird_status=""
|
||||
if timeout 0.3 netbird status >/dev/null 2>&1; then
|
||||
netbird_status=$(netbird status | grep "Networks" | cut -d: -f2 | sed "s/ -//")
|
||||
fi
|
||||
if [ -z "$netbird_status" ]; then
|
||||
echo " Start netbird"
|
||||
else
|
||||
active+="1"
|
||||
echo " Stop netbird"
|
||||
fi
|
||||
else
|
||||
echo " Netbird not installed"
|
||||
fi
|
||||
|
||||
# sing-box
|
||||
if $sing_box_installed; then
|
||||
if systemctl status sing-box >/dev/null 2>&1; then
|
||||
active+="2"
|
||||
echo " Stop sing-box"
|
||||
else
|
||||
echo " Start sing-box"
|
||||
fi
|
||||
else
|
||||
echo " Sing-box not installed"
|
||||
fi
|
||||
|
||||
echo -en "$active\n"
|
||||
@@ -1,96 +1,123 @@
|
||||
#!/bin/bash
|
||||
# Checking if programms are available
|
||||
case x"$@" in
|
||||
x" Stop wireguard")
|
||||
coproc (wg-quick down wg0 >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start wireguard")
|
||||
coproc (wg-quick up wg0 >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Stop netbird")
|
||||
coproc (netbird down >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start netbird")
|
||||
coproc (netbird up >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Stop sing-box")
|
||||
coproc (sudo systemctl stop sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
x" Start sing-box")
|
||||
coproc (sudo systemctl start sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
# Wireguard configs dir
|
||||
WG_CONF_DIR="$HOME/.wireguard"
|
||||
|
||||
# Action handler
|
||||
case "$@" in
|
||||
*'Stop wireguard ('*')')
|
||||
iface="${@##*Stop wireguard (}"
|
||||
iface="${iface%')'*}"
|
||||
if [[ "$iface" == "/etc" ]]; then
|
||||
conf="/etc/wireguard/wg0.conf"
|
||||
else
|
||||
conf="$WG_CONF_DIR/$iface.conf"
|
||||
fi
|
||||
coproc (wg-quick down "$conf" >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
*'Start wireguard ('*')')
|
||||
iface="${@##*Start wireguard (}"
|
||||
iface="${iface%')'*}"
|
||||
if [[ "$iface" == "/etc" ]]; then
|
||||
conf="/etc/wireguard/wg0.conf"
|
||||
else
|
||||
conf="$WG_CONF_DIR/$iface.conf"
|
||||
fi
|
||||
coproc (wg-quick up "$conf" >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
*'Stop netbird'*)
|
||||
coproc (netbird down >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
*'Start netbird'*)
|
||||
coproc (netbird up >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
*'Stop sing-box'*)
|
||||
coproc (sudo systemctl stop sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
*'Start sing-box'*)
|
||||
coproc (sudo systemctl start sing-box >/dev/null 2>&1) &
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# Checking if programms are installed
|
||||
wireguard_installed=true
|
||||
if ! command -v wg-quick >/dev/null 2>&1; then
|
||||
wireguard_installed=false
|
||||
else
|
||||
wireguard_installed=true
|
||||
# Find wireguard configs
|
||||
wg_configs=()
|
||||
if [ -d "$WG_CONF_DIR" ]; then
|
||||
for conf in "$WG_CONF_DIR"/*.conf; do
|
||||
[ -f "$conf" ] && wg_configs+=("$conf")
|
||||
done
|
||||
fi
|
||||
|
||||
netbird_installed=true
|
||||
if ! command -v netbird >/dev/null 2>&1; then
|
||||
netbird_installed=false
|
||||
else
|
||||
netbird_installed=true
|
||||
fi
|
||||
|
||||
sing_box_installed=true
|
||||
if ! systemctl list-unit-files -q sing-box.service >/dev/null 2>&1; then
|
||||
sing_box_installed=false
|
||||
else
|
||||
sing_box_installed=true
|
||||
fi
|
||||
|
||||
# active param
|
||||
active="\0active\x1f"
|
||||
# Build menu
|
||||
index=0
|
||||
active_indices=()
|
||||
|
||||
# wireguard
|
||||
if $wireguard_installed; then
|
||||
wireguard_status=$(sudo wg show interfaces)
|
||||
if [ "$wireguard_status" != "wg0" ]; then
|
||||
echo " Start wireguard"
|
||||
else
|
||||
active+="0"
|
||||
echo " Stop wireguard"
|
||||
fi
|
||||
if command -v wg-quick >/dev/null 2>&1; then
|
||||
if [ ${#wg_configs[@]} -gt 0 ]; then
|
||||
for conf in "${wg_configs[@]}"; do
|
||||
iface=$(basename "$conf" .conf)
|
||||
if sudo wg show "$iface" &>/dev/null; then
|
||||
echo " Stop wireguard ($iface)"
|
||||
active_indices+=($index)
|
||||
else
|
||||
echo " Start wireguard ($iface)"
|
||||
fi
|
||||
((index++))
|
||||
done
|
||||
else
|
||||
# use /etc/wireguard/wg0.conf if no files found
|
||||
if sudo wg show wg0 &>/dev/null; then
|
||||
echo " Stop wireguard (/etc)"
|
||||
active_indices+=($index)
|
||||
else
|
||||
echo " Start wireguard (/etc)"
|
||||
fi
|
||||
((index++))
|
||||
fi
|
||||
else
|
||||
echo " Wireguard not installed"
|
||||
echo " Wireguard not installed"
|
||||
((index++))
|
||||
fi
|
||||
|
||||
# netbird
|
||||
if $netbird_installed; then
|
||||
netbird_status=""
|
||||
if timeout 0.3 netbird status >/dev/null 2>&1; then
|
||||
netbird_status=$(netbird status | grep "Networks" | cut -d: -f2 | sed "s/ -//")
|
||||
fi
|
||||
if [ -z "$netbird_status" ]; then
|
||||
echo " Start netbird"
|
||||
else
|
||||
active+="1"
|
||||
echo " Stop netbird"
|
||||
fi
|
||||
if command -v netbird >/dev/null 2>&1; then
|
||||
netbird_status=""
|
||||
if timeout 0.3 netbird status >/dev/null 2>&1; then
|
||||
netbird_status=$(netbird status | grep "Networks" | cut -d: -f2 | sed "s/ -//")
|
||||
fi
|
||||
if [ -z "$netbird_status" ]; then
|
||||
echo " Start netbird"
|
||||
else
|
||||
echo " Stop netbird"
|
||||
active_indices+=($index)
|
||||
fi
|
||||
((index++))
|
||||
else
|
||||
echo " Netbird not installed"
|
||||
echo " Netbird not installed"
|
||||
((index++))
|
||||
fi
|
||||
|
||||
# sing-box
|
||||
if $sing_box_installed; then
|
||||
if systemctl status sing-box >/dev/null 2>&1; then
|
||||
active+="2"
|
||||
echo " Stop sing-box"
|
||||
else
|
||||
echo " Start sing-box"
|
||||
fi
|
||||
if systemctl list-unit-files -q sing-box.service >/dev/null 2>&1; then
|
||||
if systemctl status sing-box >/dev/null 2>&1; then
|
||||
echo " Stop sing-box"
|
||||
active_indices+=($index)
|
||||
else
|
||||
echo " Start sing-box"
|
||||
fi
|
||||
((index++))
|
||||
else
|
||||
echo " Sing-box not installed"
|
||||
echo " Sing-box not installed"
|
||||
((index++))
|
||||
fi
|
||||
|
||||
echo -en "$active\n"
|
||||
# Tell rofi which lines are active
|
||||
if [ ${#active_indices[@]} -gt 0 ]; then
|
||||
active_str=$(printf "%s" "${active_indices[@]}")
|
||||
echo -en "\0active\x1f$active_str\n"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user