Select language when launching a guest session











up vote
3
down vote

favorite
3












I've run into a tricky situation.



I'm setting up a public-access computer, where it is desirable that people log in using the guest account.
The people who need to use the computer speak a lot of different languages.



The computer is an old one, and it's currently running Lubuntu 15.10, Lightdm login.



However, as it's only possible to switch system languages by logging out and back into an account, combined with the fact that the guest account gets wiped once it logs out...
A bit of a catch 22.



I'm probably going to have to solve this using some sort of a scripted language-picker.
I see two possible solutions, and those form my question(s):



Is there any way to change system language without a full logout?



Alternatively, is it possible to launch a script during a login? I'm thinking several different guest-account/skel alternatives, and making a symlink during login.










share|improve this question




























    up vote
    3
    down vote

    favorite
    3












    I've run into a tricky situation.



    I'm setting up a public-access computer, where it is desirable that people log in using the guest account.
    The people who need to use the computer speak a lot of different languages.



    The computer is an old one, and it's currently running Lubuntu 15.10, Lightdm login.



    However, as it's only possible to switch system languages by logging out and back into an account, combined with the fact that the guest account gets wiped once it logs out...
    A bit of a catch 22.



    I'm probably going to have to solve this using some sort of a scripted language-picker.
    I see two possible solutions, and those form my question(s):



    Is there any way to change system language without a full logout?



    Alternatively, is it possible to launch a script during a login? I'm thinking several different guest-account/skel alternatives, and making a symlink during login.










    share|improve this question


























      up vote
      3
      down vote

      favorite
      3









      up vote
      3
      down vote

      favorite
      3






      3





      I've run into a tricky situation.



      I'm setting up a public-access computer, where it is desirable that people log in using the guest account.
      The people who need to use the computer speak a lot of different languages.



      The computer is an old one, and it's currently running Lubuntu 15.10, Lightdm login.



      However, as it's only possible to switch system languages by logging out and back into an account, combined with the fact that the guest account gets wiped once it logs out...
      A bit of a catch 22.



      I'm probably going to have to solve this using some sort of a scripted language-picker.
      I see two possible solutions, and those form my question(s):



      Is there any way to change system language without a full logout?



      Alternatively, is it possible to launch a script during a login? I'm thinking several different guest-account/skel alternatives, and making a symlink during login.










      share|improve this question















      I've run into a tricky situation.



      I'm setting up a public-access computer, where it is desirable that people log in using the guest account.
      The people who need to use the computer speak a lot of different languages.



      The computer is an old one, and it's currently running Lubuntu 15.10, Lightdm login.



      However, as it's only possible to switch system languages by logging out and back into an account, combined with the fact that the guest account gets wiped once it logs out...
      A bit of a catch 22.



      I'm probably going to have to solve this using some sort of a scripted language-picker.
      I see two possible solutions, and those form my question(s):



      Is there any way to change system language without a full logout?



      Alternatively, is it possible to launch a script during a login? I'm thinking several different guest-account/skel alternatives, and making a symlink during login.







      login language guest-session






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 20 '16 at 21:51









      Gunnar Hjalmarsson

      19k23261




      19k23261










      asked Apr 19 '16 at 19:27









      sverker wahlin

      418210




      418210






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          It's possible to change the environment variables LANG and LANGUAGE within the session, but it won't affect already running processes. So no, there is no practical way to do it without logging out.



          Considering that lightdm-gtk-greeter already has a language selector for choosing the language when you log in to an ordinary account, the most elegant solution would probably be to somehow make use of that feature. Can't tell how, though...



          The below example solution uses a wrapper script to let the user select the display language via a zenity dialog. The example includes English and Swedish; the languages you use must of course be installed. This solution should work with both unity-greeter and lightdm-gtk-greeter on later Ubuntu versions. I tested on 15.10 and 16.04.



          Create /etc/guest-session/choose-language-wrapper.sh, give it this contents:



          #!/bin/sh -e

          # show zenity dialog only when launched from greeter
          ONLYGUEST=true
          for U in $(users); do
          if [ "${U%%-*}" != 'guest' ]; then
          ONLYGUEST=false
          break
          fi
          done

          if $ONLYGUEST && [ -x /usr/bin/zenity ]; then
          guestlang=$( zenity --list --title 'Select language'
          --text 'Select language for the guest session' --radiolist
          --column 'Pick' --column '' TRUE 'English' FALSE 'Swedish' )
          if [ "$guestlang" = 'English' ]; then
          echo 'export LANGUAGE=en_US' >> "$HOME/.profile"
          echo 'export LANG=en_US.UTF-8' >> "$HOME/.profile"
          elif [ "$guestlang" = 'Swedish' ]; then
          echo 'export LANGUAGE=sv' >> "$HOME/.profile"
          echo 'export LANG=sv_SE.UTF-8' >> "$HOME/.profile"
          fi
          fi

          exec /usr/lib/lightdm/lightdm-guest-session "$@"


          and make it executable:



          sudo chmod +x /etc/guest-session/choose-language-wrapper.sh


          Then make lightdm use the wrapper script by creating this file:



          $ cat /etc/lightdm/lightdm.conf.d/50-choose-guest-language.conf
          [Seat:*]
          guest-wrapper=/etc/guest-session/choose-language-wrapper.sh


          After next reboot the zenity dialog should show up when launching a guest session from the greeter.






          share|improve this answer























          • This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
            – sverker wahlin
            Apr 20 '16 at 10:40






          • 1




            @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 13:13






          • 1




            @sverkerwahlin: Figured out a solution and edited my answer.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 21:44










          • oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
            – sverker wahlin
            Apr 20 '16 at 22:03










          • @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 22:04











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f759218%2fselect-language-when-launching-a-guest-session%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          It's possible to change the environment variables LANG and LANGUAGE within the session, but it won't affect already running processes. So no, there is no practical way to do it without logging out.



          Considering that lightdm-gtk-greeter already has a language selector for choosing the language when you log in to an ordinary account, the most elegant solution would probably be to somehow make use of that feature. Can't tell how, though...



          The below example solution uses a wrapper script to let the user select the display language via a zenity dialog. The example includes English and Swedish; the languages you use must of course be installed. This solution should work with both unity-greeter and lightdm-gtk-greeter on later Ubuntu versions. I tested on 15.10 and 16.04.



          Create /etc/guest-session/choose-language-wrapper.sh, give it this contents:



          #!/bin/sh -e

          # show zenity dialog only when launched from greeter
          ONLYGUEST=true
          for U in $(users); do
          if [ "${U%%-*}" != 'guest' ]; then
          ONLYGUEST=false
          break
          fi
          done

          if $ONLYGUEST && [ -x /usr/bin/zenity ]; then
          guestlang=$( zenity --list --title 'Select language'
          --text 'Select language for the guest session' --radiolist
          --column 'Pick' --column '' TRUE 'English' FALSE 'Swedish' )
          if [ "$guestlang" = 'English' ]; then
          echo 'export LANGUAGE=en_US' >> "$HOME/.profile"
          echo 'export LANG=en_US.UTF-8' >> "$HOME/.profile"
          elif [ "$guestlang" = 'Swedish' ]; then
          echo 'export LANGUAGE=sv' >> "$HOME/.profile"
          echo 'export LANG=sv_SE.UTF-8' >> "$HOME/.profile"
          fi
          fi

          exec /usr/lib/lightdm/lightdm-guest-session "$@"


          and make it executable:



          sudo chmod +x /etc/guest-session/choose-language-wrapper.sh


          Then make lightdm use the wrapper script by creating this file:



          $ cat /etc/lightdm/lightdm.conf.d/50-choose-guest-language.conf
          [Seat:*]
          guest-wrapper=/etc/guest-session/choose-language-wrapper.sh


          After next reboot the zenity dialog should show up when launching a guest session from the greeter.






          share|improve this answer























          • This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
            – sverker wahlin
            Apr 20 '16 at 10:40






          • 1




            @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 13:13






          • 1




            @sverkerwahlin: Figured out a solution and edited my answer.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 21:44










          • oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
            – sverker wahlin
            Apr 20 '16 at 22:03










          • @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 22:04















          up vote
          2
          down vote



          accepted










          It's possible to change the environment variables LANG and LANGUAGE within the session, but it won't affect already running processes. So no, there is no practical way to do it without logging out.



          Considering that lightdm-gtk-greeter already has a language selector for choosing the language when you log in to an ordinary account, the most elegant solution would probably be to somehow make use of that feature. Can't tell how, though...



          The below example solution uses a wrapper script to let the user select the display language via a zenity dialog. The example includes English and Swedish; the languages you use must of course be installed. This solution should work with both unity-greeter and lightdm-gtk-greeter on later Ubuntu versions. I tested on 15.10 and 16.04.



          Create /etc/guest-session/choose-language-wrapper.sh, give it this contents:



          #!/bin/sh -e

          # show zenity dialog only when launched from greeter
          ONLYGUEST=true
          for U in $(users); do
          if [ "${U%%-*}" != 'guest' ]; then
          ONLYGUEST=false
          break
          fi
          done

          if $ONLYGUEST && [ -x /usr/bin/zenity ]; then
          guestlang=$( zenity --list --title 'Select language'
          --text 'Select language for the guest session' --radiolist
          --column 'Pick' --column '' TRUE 'English' FALSE 'Swedish' )
          if [ "$guestlang" = 'English' ]; then
          echo 'export LANGUAGE=en_US' >> "$HOME/.profile"
          echo 'export LANG=en_US.UTF-8' >> "$HOME/.profile"
          elif [ "$guestlang" = 'Swedish' ]; then
          echo 'export LANGUAGE=sv' >> "$HOME/.profile"
          echo 'export LANG=sv_SE.UTF-8' >> "$HOME/.profile"
          fi
          fi

          exec /usr/lib/lightdm/lightdm-guest-session "$@"


          and make it executable:



          sudo chmod +x /etc/guest-session/choose-language-wrapper.sh


          Then make lightdm use the wrapper script by creating this file:



          $ cat /etc/lightdm/lightdm.conf.d/50-choose-guest-language.conf
          [Seat:*]
          guest-wrapper=/etc/guest-session/choose-language-wrapper.sh


          After next reboot the zenity dialog should show up when launching a guest session from the greeter.






          share|improve this answer























          • This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
            – sverker wahlin
            Apr 20 '16 at 10:40






          • 1




            @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 13:13






          • 1




            @sverkerwahlin: Figured out a solution and edited my answer.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 21:44










          • oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
            – sverker wahlin
            Apr 20 '16 at 22:03










          • @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 22:04













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          It's possible to change the environment variables LANG and LANGUAGE within the session, but it won't affect already running processes. So no, there is no practical way to do it without logging out.



          Considering that lightdm-gtk-greeter already has a language selector for choosing the language when you log in to an ordinary account, the most elegant solution would probably be to somehow make use of that feature. Can't tell how, though...



          The below example solution uses a wrapper script to let the user select the display language via a zenity dialog. The example includes English and Swedish; the languages you use must of course be installed. This solution should work with both unity-greeter and lightdm-gtk-greeter on later Ubuntu versions. I tested on 15.10 and 16.04.



          Create /etc/guest-session/choose-language-wrapper.sh, give it this contents:



          #!/bin/sh -e

          # show zenity dialog only when launched from greeter
          ONLYGUEST=true
          for U in $(users); do
          if [ "${U%%-*}" != 'guest' ]; then
          ONLYGUEST=false
          break
          fi
          done

          if $ONLYGUEST && [ -x /usr/bin/zenity ]; then
          guestlang=$( zenity --list --title 'Select language'
          --text 'Select language for the guest session' --radiolist
          --column 'Pick' --column '' TRUE 'English' FALSE 'Swedish' )
          if [ "$guestlang" = 'English' ]; then
          echo 'export LANGUAGE=en_US' >> "$HOME/.profile"
          echo 'export LANG=en_US.UTF-8' >> "$HOME/.profile"
          elif [ "$guestlang" = 'Swedish' ]; then
          echo 'export LANGUAGE=sv' >> "$HOME/.profile"
          echo 'export LANG=sv_SE.UTF-8' >> "$HOME/.profile"
          fi
          fi

          exec /usr/lib/lightdm/lightdm-guest-session "$@"


          and make it executable:



          sudo chmod +x /etc/guest-session/choose-language-wrapper.sh


          Then make lightdm use the wrapper script by creating this file:



          $ cat /etc/lightdm/lightdm.conf.d/50-choose-guest-language.conf
          [Seat:*]
          guest-wrapper=/etc/guest-session/choose-language-wrapper.sh


          After next reboot the zenity dialog should show up when launching a guest session from the greeter.






          share|improve this answer














          It's possible to change the environment variables LANG and LANGUAGE within the session, but it won't affect already running processes. So no, there is no practical way to do it without logging out.



          Considering that lightdm-gtk-greeter already has a language selector for choosing the language when you log in to an ordinary account, the most elegant solution would probably be to somehow make use of that feature. Can't tell how, though...



          The below example solution uses a wrapper script to let the user select the display language via a zenity dialog. The example includes English and Swedish; the languages you use must of course be installed. This solution should work with both unity-greeter and lightdm-gtk-greeter on later Ubuntu versions. I tested on 15.10 and 16.04.



          Create /etc/guest-session/choose-language-wrapper.sh, give it this contents:



          #!/bin/sh -e

          # show zenity dialog only when launched from greeter
          ONLYGUEST=true
          for U in $(users); do
          if [ "${U%%-*}" != 'guest' ]; then
          ONLYGUEST=false
          break
          fi
          done

          if $ONLYGUEST && [ -x /usr/bin/zenity ]; then
          guestlang=$( zenity --list --title 'Select language'
          --text 'Select language for the guest session' --radiolist
          --column 'Pick' --column '' TRUE 'English' FALSE 'Swedish' )
          if [ "$guestlang" = 'English' ]; then
          echo 'export LANGUAGE=en_US' >> "$HOME/.profile"
          echo 'export LANG=en_US.UTF-8' >> "$HOME/.profile"
          elif [ "$guestlang" = 'Swedish' ]; then
          echo 'export LANGUAGE=sv' >> "$HOME/.profile"
          echo 'export LANG=sv_SE.UTF-8' >> "$HOME/.profile"
          fi
          fi

          exec /usr/lib/lightdm/lightdm-guest-session "$@"


          and make it executable:



          sudo chmod +x /etc/guest-session/choose-language-wrapper.sh


          Then make lightdm use the wrapper script by creating this file:



          $ cat /etc/lightdm/lightdm.conf.d/50-choose-guest-language.conf
          [Seat:*]
          guest-wrapper=/etc/guest-session/choose-language-wrapper.sh


          After next reboot the zenity dialog should show up when launching a guest session from the greeter.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 6 '16 at 21:23

























          answered Apr 19 '16 at 22:32









          Gunnar Hjalmarsson

          19k23261




          19k23261












          • This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
            – sverker wahlin
            Apr 20 '16 at 10:40






          • 1




            @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 13:13






          • 1




            @sverkerwahlin: Figured out a solution and edited my answer.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 21:44










          • oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
            – sverker wahlin
            Apr 20 '16 at 22:03










          • @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 22:04


















          • This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
            – sverker wahlin
            Apr 20 '16 at 10:40






          • 1




            @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 13:13






          • 1




            @sverkerwahlin: Figured out a solution and edited my answer.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 21:44










          • oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
            – sverker wahlin
            Apr 20 '16 at 22:03










          • @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
            – Gunnar Hjalmarsson
            Apr 20 '16 at 22:04
















          This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
          – sverker wahlin
          Apr 20 '16 at 10:40




          This kind of zenity-chooser-window would actually be better for my situation. The guest users are sometimes not very computer-savvy, so it's better to have the chooser in their faces, as opposed to hidden in a bin icon.
          – sverker wahlin
          Apr 20 '16 at 10:40




          1




          1




          @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 13:13




          @sverkerwahlin: I have an idea. Will get back to you in a couple of days.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 13:13




          1




          1




          @sverkerwahlin: Figured out a solution and edited my answer.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 21:44




          @sverkerwahlin: Figured out a solution and edited my answer.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 21:44












          oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
          – sverker wahlin
          Apr 20 '16 at 22:03




          oh this looks perfect! I'll give this a try tomorrow. Actually, I think I'll see if I can't send the lightdm-guest-session path as a argument to the script, so that the original path will still be in the lightdm.conf.d file. It feels like that might make it more robust if future updates want to change that path.
          – sverker wahlin
          Apr 20 '16 at 22:03












          @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 22:04




          @sverkerwahlin: Not sure I understand. Anyway, would appreciate feedback when you have tested.
          – Gunnar Hjalmarsson
          Apr 20 '16 at 22:04


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f759218%2fselect-language-when-launching-a-guest-session%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Category:香港粉麵

          List *all* the tuples!

          Channel [V]