points/bin/once-connected.zsh

86 lines
1.7 KiB
Bash
Raw Normal View History

2023-03-24 21:12:45 +01:00
#!/bin/zsh
# vi:spl=en
alias xterm='xterm -bg black -fg white -fa Hack -fs 10'
2024-01-22 16:54:59 +01:00
## Mount dev folders
#
# Note: To be done first, so other actions can use mounted folders.
#
[[ -x $HOME/bin/mount_dev.zsh ]] &&
xterm -geometry 120x40 -title "Mount devices" -hold -e $HOME/bin/mount_dev.zsh
2023-03-24 21:12:45 +01:00
## Start periodic actions
#
eval xterm -hold -e env $(cat ~/.config/environment.d/variables.conf) $HOME/bin/every-hour.zsh
2023-03-24 21:12:45 +01:00
## 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' ''
'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
}