3

I have a script to set up an ubuntu workstation with standard settings. One of the things it did on 16.04 was hide the usernames from the login screen.

Moving to 18.04 and I am having some difficulty managing to do this. From what I can see to do

gsettings set org.gnome.login-screen disable-user-list true

If I run this in a script as sudo tweaks.sh it gives errors, the only way I can manage to get it to work is manually by doing a change to gdm user

su gdm -s /bin/bash
gsettings set org.gnome.login-screen disable-user-list true
exit

I have tried the following ways to make it less interactive but all fail

sudo -u gdm -H sh -c "gsettings set org.gnome.login-screen disable-user-list true"

or

sudo -u gdm dbus-launch --exit-with-session gsettings set org.gnome.login-screen disable-user-list true

Any suggest how I can make this change from a script?

stonke
  • 41
  • According to this answer: https://askubuntu.com/a/294748/214944, you should try: sudo -H -u gdm bash -c 'gsettings set org.gnome.login-screen disable-user-list true' – ponsfrilus Jul 03 '18 at 17:32
  • @ponsfrilusl that errors with Error spwaning command line "dbus-launch --autolaunch=d3b8183928cd438fa0149f458ae87f66 --binary-syntax --close-stderr": Child process exited; – stonke Jul 03 '18 at 18:03
  • ok I think I have it working now sudo -u gdm base -c 'dbus-launch --exit-with-session gsettings set org.gnome.login-screen disable-user-list true' it does give an error of No protocol specified but gives the desired result. – stonke Jul 03 '18 at 18:11
  • Are you sure about the base command ? – ponsfrilus Jul 03 '18 at 18:30
  • woops typo should have read bash – stonke Jul 03 '18 at 18:41

1 Answers1

1

My solution thanks to help from @ponsfrilusl

sudo -u gdm bash -c 'dbus-launch --exit-with-session gsettings set org.gnome.login-screen disable-user-list true' > /dev/null 2&>1

It outputs No protocol specified this can be ignored by appending > /dev/null 2&>1 to mute this.

stonke
  • 41