Skip to content

Instantly share code, notes, and snippets.

Created May 29, 2012 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2830526 to your computer and use it in GitHub Desktop.
Save anonymous/2830526 to your computer and use it in GitHub Desktop.
stdin
#!/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