switchusers

master
Daniel Napora 2023-08-16 22:30:07 +02:00
parent d058b8db2e
commit 18ba28e5ea
1 changed files with 46 additions and 6 deletions

View File

@ -849,9 +849,21 @@ MENU_ITEMS=$(mktemp)
trap "rm -f ${CONFIG_FILE} ${MENU_ITEMS};#wmctrl -k off" EXIT
case $LANG in
pl*) CANCEL="Anuluj";;
es*) CANCEL="Cancelar";;
*) CANCEL="Cancel";;
pl*) CANCEL="Anuluj"
SWITCHUSER="Przełącz użytkownika"
SWITCHTO="Przełącz na..."
NEWSESS="Nowa sesja jako..."
;;
es*) CANCEL="Cancelar"
SWITCHUSER="Switch user"
SWITCHTO="Switch to..."
NEWSESS="New session as..."
;;
*) CANCEL="Cancel"
SWITCHUSER="Switch user"
SWITCHTO="Switch to..."
NEWSESS="New session as..."
;;
esac
jgtools_padding=${jgtools_padding:-0}
#JGWIDTH=$((jgtools_padding + 348 + jgtools_padding))
@ -865,6 +877,32 @@ item_height_factor=300
#jgmenu_font="Noto Sans Medium 11"
mkconfigfile
if pgrep -f /usr/bin/lightdm >/dev/null
then
ALLUSERS=( $(getent passwd {1000..1010}|cut -d: -f1) )
if [[ ${#ALLUSERS[@]} -gt 1 ]];then
SESSIONS=( $(dm-tool list-seats|grep UserName|cut -d"'" -f2) )
SW+=("^sep()" "$SWITCHUSER,^checkout(users),system-switch-user")
SW2+=("^tag(users)")
if [[ ${#SESSIONS[@]} -gt 1 ]];then
SW2+=("^sep($SWITCHTO)")
for usess in "${SESSIONS[@]}";do
[[ "$usess" != "$USER" ]] && SW2+=("$usess, dm-tool switch-to-user $usess,system-switch-user")
done
fi
for element in "${SESSIONS[@]}";do
ALLUSERS=(${ALLUSERS[@]/*${element}*/})
done
if [[ ${#ALLUSERS[@]} -gt 0 ]];then
SW2+=("^sep($NEWSESS)")
for u in "${ALLUSERS[@]}";do
SW2+=("$u,dm-tool switch-to-user $u,system-switch-user")
done
fi
fi
fi
#wmctrl -k on
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
@ -885,13 +923,15 @@ THUMBDIR="$HOME/.cache/colorizer/thumbs"
cat <<EOF > ${MENU_ITEMS}
@icon,,$((jgtools_padding)),$((jgtools_padding)),270,150,4,left,top,,,$THUMB
#@icon,,10,10,48,48,4,left,top,,,/usr/share/icons/hicolor/48x48/apps/mbcc.png
@text,,$((jgtools_padding + 180)),$((jgtools_padding + 170)),220,20,4,left,top,${color_sel_fg% *},${color_sel_bg% *},$OSNAME $OSVERSION <sup> $OSCODE</sup>
@text,,$((jgtools_padding + 180)),$((jgtools_padding + 190)),200,20,4,left,top,${color_norm_fg% *},#DDDDDD,<small>$USER@$HOSTNAME</small>
@rect,,$((jgtools_padding + 0)),$((jgtools_padding + 120)),270,22,2,left,top,#222222 50,#222222 80,
@text,,$((jgtools_padding + 8)),$((jgtools_padding + 120)),292,20,4,left,top,#EEEEEE,##EEEEEE,"""<span size='10400' font_family='Ubuntu'>$USER @ $HOSTNAME</span>"""
@icon,,224,108,48,48,4,left,top,,,/usr/share/icons/hicolor/48x48/apps/mbcc.png
. $HOME/.config/mabox/exit.csv
$(printf '%s\n' "${SW[@]}")
^sep()
$CANCEL <small>esc</small>,exit 1,gtk-close
$(printf '%s\n' "${SW2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null