diff options
author | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
commit | ef6dff4cce15186a66ba34cdd7bd39958ebf7f58 (patch) | |
tree | fcfa61164ca6e79c900b5d11f6afc6b46aaccb84 /.local/bin/singboxwrap | |
download | hyprdots-ef6dff4cce15186a66ba34cdd7bd39958ebf7f58.tar.gz |
first commit
Diffstat (limited to '.local/bin/singboxwrap')
-rwxr-xr-x | .local/bin/singboxwrap | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/.local/bin/singboxwrap b/.local/bin/singboxwrap new file mode 100755 index 0000000..e52db36 --- /dev/null +++ b/.local/bin/singboxwrap @@ -0,0 +1,32 @@ +#!/bin/sh + +config_dir="/mnt/ssd/settings/sing-box" +default_path="${XDG_DATA_HOME:-$HOME/.local/share}/singboxcfg" + +input=$1 + +run_singbox () { + sing-box check -c "$1" && { + pidof sing-box >/dev/null && killall sing-box + setsid -f sing-box -c "$1" run + if [ "$input" = menu ]; then + notify-send "sing-box with $(readlink "$1") is running now" + fi + } || notify-send "Config check has failed. Check your configuration at $(readlink $1)" & exit 1 +} + +choose_menu () { + choose="$(fd . $config_dir -d 1 -t f | mew -p "Config to use")" + [ -n "$choose" ] || exit 1 + ln -sf "$choose" "$default_path" + echo "$default_path" +} + +if [ ! -f "$default_path" ]; then + input="menu" +fi + +case $input in + menu) run_singbox $(choose_menu) ;; + *) run_singbox $default_path ;; +esac |