Created
May 29, 2012 20:31
-
-
Save anonymous/2830526 to your computer and use it in GitHub Desktop.
stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -f # no globbing, so we can safely use * | |
# other_local[joe]=:0, other_local[bob]=:1 etc. for all active local | |
# users other than us: | |
unset other_local; declare -A other_local; | |
while read -rd $'\t'; do | |
IFS=$',\n' r=($REPLY) | |
[[ "${#r[@]}" -ge 4 && "${r[4]}" != '*' && "${r[2]}" != '' && "${r[0]}" != '' ]] && other_local[${r[2]}]=${r[0]} | |
done < <(kdmctl list alllocal) | |
IFS=$',\n' r=($REPLY) | |
[[ "${#r[@]}" -ge 4 && "${r[4]}" != '*' && "${r[2]}" != '' && "${r[0]}" != '' ]] && other_local[${r[2]}]=${r[0]} | |
user_choice=$( printf "%s\n" "${!other_local[@]}" "New login" |\ | |
zenity --list --column User --text 'Switch to an active user, or start a new login:' --title 'Switch user?' ) || exit 1 | |
case $user_choice in | |
"New login" ) kdmctl reserve ;; | |
* ) kdmctl activate "${other_local[$user_choice]}" ;; | |
esac | |
#for i in "${!other_local[@]}"; do echo "key : $i"; echo "value: ${other_local[$i]}"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment