singboxwrap (787B)
1 #!/bin/sh 2 3 config_dir="/mnt/ssd/settings/sing-box" 4 default_path="${XDG_DATA_HOME:-$HOME/.local/share}/singboxcfg" 5 6 input=$1 7 8 run_singbox () { 9 sing-box check -c "$1" && { 10 pidof sing-box >/dev/null && killall sing-box 11 setsid -f sing-box -c "$1" run 12 if [ "$input" = menu ]; then 13 notify-send "sing-box with $(readlink "$1") is running now" 14 fi 15 } || notify-send "Config check has failed. Check your configuration at $(readlink $1)" & exit 1 16 } 17 18 choose_menu () { 19 choose="$(ls $config_dir | wmenu -p "Config to use")" 20 [ -n "$choose" ] || exit 1 21 ln -sf "$config_dir/$choose" "$default_path" 22 echo "$default_path" 23 } 24 25 if [ ! -f "$default_path" ]; then 26 input="menu" 27 fi 28 29 case $input in 30 menu) run_singbox $(choose_menu) ;; 31 *) run_singbox $default_path ;; 32 esac