points/bin/once-connected.zsh
2023-03-24 21:12:45 +01:00

79 lines
1.5 KiB
Bash
Executable File

#!/bin/zsh
# vi:spl=en
alias xterm='xterm -bg black -fg white -fa Hack -fs 10'
## Start periodic actions
#
$HOME/bin/every-hour.zsh
## Wait for an Internet connection
#
while ! nm-online -t 5 ; do
List=( $(nmcli connection show | grep wifi | cut -d' ' -f1) )
Menu=()
for Name in $List;
Menu+=( "$Name" "$Name" )
Conn=$(kdialog --menu "Aucune connexion active\nLaquelle choisir?" $Menu)
if [[ $? -eq 0 ]]; then
nmcli radio wifi on
sleep 3
nmcli connection up $Conn
else
exit 1
fi
done
## Activating services
#
# See:
# - https://software.opensuse.org/download.html?project=home%3Anpreining%3Adebian-ubuntu-onedrive&package=onedrive
# - https://software.opensuse.org/download.html?project=home%3Ajstaf&package=onedriver
PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/.asdf/bin
Services=(
'firefox -P michel' 'off' ''
'firefox -P vedecom' 'off' ''
'firefox -P ''$oft''' 'off' ''
'onedrive-d1-os4.zsh' 'off' ''
'onedriver-launcher' 'off' ''
'asdf update; asdf plugin update --all' 'off' 'xterm'
)
Menu=()
count=0
for i in {1..$#Services..3} ; {
(( count+=1 ))
Command=${Services[$i]}
Enable=${Services[$i+1]}
Menu+=( ${count} ${Command} ${Enable} )
}
Indexes=( $(kdialog --geometry 600x300 --checklist "Applications à démarrer" $Menu) )
for i in $Indexes ;
{
i=${i//\"/}
i=$((3*i - 2))
Command=${Services[$i]}
Option=${Services[$i+2]}
case ${Option} in
xterm)
xterm -hold -e ${Command} &
;;
*)
${=Command} &
;;
esac
}