Opening .desktop file outside of desktop immediately logs out

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












This is my first question with Ask Ubuntu, so I'd like to thank you in advance for your patience.



My situation is this:
I have a *.desktop file (which I wrote) that is supposed to execute a shell script. My initial intent was to place this file in ~/.config/autostart so that it would run automatically at startup; however, this causes Ubuntu to flash the desktop for a split second, then log me back out. I can double click the file on my desktop and it will launch the script like it's supposed to. If I take the *.desktop file out of the ~/Desktop directory and put it literally anywhere else, double clicking it in Nautilus will also result in me being logged out immediately.



The *.desktop file is set to execute a shell script which starts bash in gnome-terminal. My reasons for doing this are not necessarily important, so please assume that that's the way I need it to be. If I add sleep 10 to the beginning of the first shell script, I am logged out 10 seconds after starting the *.desktop file, regardless of how it is started. It seems like the problem is in the fact that a new gnome-terminal window is started from the second script, but I don't understand how or why this would be.
Desktop entry:



[Desktop entry]
Name=Autocapture
Comment=Starts autocap program
Exec=/Autocapture/Startup/InitSystem
Terminal=false
Type=Application


InitSystem:



#!/bin/bash
nohup gnome-terminal --title=Autocapture --maximize -e "bash -c 'bash /Autocapture/Startup/StartAutocap.sh';bash"
wmctrl -a "Autocapture" # Give focus to new terminal window
kill -9 $PPID # Close this terminal


StartAutocap.sh:



#!/bin/bash
source /usr/local/bin/virtualenvwrapper.sh
workon Autocap
python /path/to/python/module.py


This is supposed to (and successfully does, if launched from desktop) start a fullscreen gnome-terminal window running bash and launch the "module.py" program in that bash session. It also closes the first gnome-terminal window that started and detached the child process.



Sorry for the incredibly long first post. I just want to understand what is going wrong here and how I might be able to fix it. Any help is greatly appreciated!







share|improve this question























    up vote
    2
    down vote

    favorite












    This is my first question with Ask Ubuntu, so I'd like to thank you in advance for your patience.



    My situation is this:
    I have a *.desktop file (which I wrote) that is supposed to execute a shell script. My initial intent was to place this file in ~/.config/autostart so that it would run automatically at startup; however, this causes Ubuntu to flash the desktop for a split second, then log me back out. I can double click the file on my desktop and it will launch the script like it's supposed to. If I take the *.desktop file out of the ~/Desktop directory and put it literally anywhere else, double clicking it in Nautilus will also result in me being logged out immediately.



    The *.desktop file is set to execute a shell script which starts bash in gnome-terminal. My reasons for doing this are not necessarily important, so please assume that that's the way I need it to be. If I add sleep 10 to the beginning of the first shell script, I am logged out 10 seconds after starting the *.desktop file, regardless of how it is started. It seems like the problem is in the fact that a new gnome-terminal window is started from the second script, but I don't understand how or why this would be.
    Desktop entry:



    [Desktop entry]
    Name=Autocapture
    Comment=Starts autocap program
    Exec=/Autocapture/Startup/InitSystem
    Terminal=false
    Type=Application


    InitSystem:



    #!/bin/bash
    nohup gnome-terminal --title=Autocapture --maximize -e "bash -c 'bash /Autocapture/Startup/StartAutocap.sh';bash"
    wmctrl -a "Autocapture" # Give focus to new terminal window
    kill -9 $PPID # Close this terminal


    StartAutocap.sh:



    #!/bin/bash
    source /usr/local/bin/virtualenvwrapper.sh
    workon Autocap
    python /path/to/python/module.py


    This is supposed to (and successfully does, if launched from desktop) start a fullscreen gnome-terminal window running bash and launch the "module.py" program in that bash session. It also closes the first gnome-terminal window that started and detached the child process.



    Sorry for the incredibly long first post. I just want to understand what is going wrong here and how I might be able to fix it. Any help is greatly appreciated!







    share|improve this question





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      This is my first question with Ask Ubuntu, so I'd like to thank you in advance for your patience.



      My situation is this:
      I have a *.desktop file (which I wrote) that is supposed to execute a shell script. My initial intent was to place this file in ~/.config/autostart so that it would run automatically at startup; however, this causes Ubuntu to flash the desktop for a split second, then log me back out. I can double click the file on my desktop and it will launch the script like it's supposed to. If I take the *.desktop file out of the ~/Desktop directory and put it literally anywhere else, double clicking it in Nautilus will also result in me being logged out immediately.



      The *.desktop file is set to execute a shell script which starts bash in gnome-terminal. My reasons for doing this are not necessarily important, so please assume that that's the way I need it to be. If I add sleep 10 to the beginning of the first shell script, I am logged out 10 seconds after starting the *.desktop file, regardless of how it is started. It seems like the problem is in the fact that a new gnome-terminal window is started from the second script, but I don't understand how or why this would be.
      Desktop entry:



      [Desktop entry]
      Name=Autocapture
      Comment=Starts autocap program
      Exec=/Autocapture/Startup/InitSystem
      Terminal=false
      Type=Application


      InitSystem:



      #!/bin/bash
      nohup gnome-terminal --title=Autocapture --maximize -e "bash -c 'bash /Autocapture/Startup/StartAutocap.sh';bash"
      wmctrl -a "Autocapture" # Give focus to new terminal window
      kill -9 $PPID # Close this terminal


      StartAutocap.sh:



      #!/bin/bash
      source /usr/local/bin/virtualenvwrapper.sh
      workon Autocap
      python /path/to/python/module.py


      This is supposed to (and successfully does, if launched from desktop) start a fullscreen gnome-terminal window running bash and launch the "module.py" program in that bash session. It also closes the first gnome-terminal window that started and detached the child process.



      Sorry for the incredibly long first post. I just want to understand what is going wrong here and how I might be able to fix it. Any help is greatly appreciated!







      share|improve this question











      This is my first question with Ask Ubuntu, so I'd like to thank you in advance for your patience.



      My situation is this:
      I have a *.desktop file (which I wrote) that is supposed to execute a shell script. My initial intent was to place this file in ~/.config/autostart so that it would run automatically at startup; however, this causes Ubuntu to flash the desktop for a split second, then log me back out. I can double click the file on my desktop and it will launch the script like it's supposed to. If I take the *.desktop file out of the ~/Desktop directory and put it literally anywhere else, double clicking it in Nautilus will also result in me being logged out immediately.



      The *.desktop file is set to execute a shell script which starts bash in gnome-terminal. My reasons for doing this are not necessarily important, so please assume that that's the way I need it to be. If I add sleep 10 to the beginning of the first shell script, I am logged out 10 seconds after starting the *.desktop file, regardless of how it is started. It seems like the problem is in the fact that a new gnome-terminal window is started from the second script, but I don't understand how or why this would be.
      Desktop entry:



      [Desktop entry]
      Name=Autocapture
      Comment=Starts autocap program
      Exec=/Autocapture/Startup/InitSystem
      Terminal=false
      Type=Application


      InitSystem:



      #!/bin/bash
      nohup gnome-terminal --title=Autocapture --maximize -e "bash -c 'bash /Autocapture/Startup/StartAutocap.sh';bash"
      wmctrl -a "Autocapture" # Give focus to new terminal window
      kill -9 $PPID # Close this terminal


      StartAutocap.sh:



      #!/bin/bash
      source /usr/local/bin/virtualenvwrapper.sh
      workon Autocap
      python /path/to/python/module.py


      This is supposed to (and successfully does, if launched from desktop) start a fullscreen gnome-terminal window running bash and launch the "module.py" program in that bash session. It also closes the first gnome-terminal window that started and detached the child process.



      Sorry for the incredibly long first post. I just want to understand what is going wrong here and how I might be able to fix it. Any help is greatly appreciated!









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 4 at 20:38









      TheIntern

      312




      312




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          While I have my theories, I am afraid to proclaim that I know exactly (or even remotely) how or why this works. I would imagine that it has something to do with the way a *.desktop launcher executes its target. Perhaps I was trying to kill the gnome-terminal window after it had already been closed at the end of the script's execution and ended up killing my session? Maybe vice versa? I don't claim to know, but I would invite anyone who does to please answer this question with your explanation so that others may learn from my mistake.



          Removing the line kill -9 $PPID solved the problem



          If the script is executed from the *.desktop launcher, the initial gnome-terminal window will close, leaving the second. If the script is executed from the command line (for example, $ bash InitSystem), the initial gnome-terminal window does not close.






          share|improve this answer























          • I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
            – Paul Stelian
            Jun 4 at 21:27










          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          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%2f1043615%2fopening-desktop-file-outside-of-desktop-immediately-logs-out%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          While I have my theories, I am afraid to proclaim that I know exactly (or even remotely) how or why this works. I would imagine that it has something to do with the way a *.desktop launcher executes its target. Perhaps I was trying to kill the gnome-terminal window after it had already been closed at the end of the script's execution and ended up killing my session? Maybe vice versa? I don't claim to know, but I would invite anyone who does to please answer this question with your explanation so that others may learn from my mistake.



          Removing the line kill -9 $PPID solved the problem



          If the script is executed from the *.desktop launcher, the initial gnome-terminal window will close, leaving the second. If the script is executed from the command line (for example, $ bash InitSystem), the initial gnome-terminal window does not close.






          share|improve this answer























          • I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
            – Paul Stelian
            Jun 4 at 21:27














          up vote
          2
          down vote













          While I have my theories, I am afraid to proclaim that I know exactly (or even remotely) how or why this works. I would imagine that it has something to do with the way a *.desktop launcher executes its target. Perhaps I was trying to kill the gnome-terminal window after it had already been closed at the end of the script's execution and ended up killing my session? Maybe vice versa? I don't claim to know, but I would invite anyone who does to please answer this question with your explanation so that others may learn from my mistake.



          Removing the line kill -9 $PPID solved the problem



          If the script is executed from the *.desktop launcher, the initial gnome-terminal window will close, leaving the second. If the script is executed from the command line (for example, $ bash InitSystem), the initial gnome-terminal window does not close.






          share|improve this answer























          • I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
            – Paul Stelian
            Jun 4 at 21:27












          up vote
          2
          down vote










          up vote
          2
          down vote









          While I have my theories, I am afraid to proclaim that I know exactly (or even remotely) how or why this works. I would imagine that it has something to do with the way a *.desktop launcher executes its target. Perhaps I was trying to kill the gnome-terminal window after it had already been closed at the end of the script's execution and ended up killing my session? Maybe vice versa? I don't claim to know, but I would invite anyone who does to please answer this question with your explanation so that others may learn from my mistake.



          Removing the line kill -9 $PPID solved the problem



          If the script is executed from the *.desktop launcher, the initial gnome-terminal window will close, leaving the second. If the script is executed from the command line (for example, $ bash InitSystem), the initial gnome-terminal window does not close.






          share|improve this answer















          While I have my theories, I am afraid to proclaim that I know exactly (or even remotely) how or why this works. I would imagine that it has something to do with the way a *.desktop launcher executes its target. Perhaps I was trying to kill the gnome-terminal window after it had already been closed at the end of the script's execution and ended up killing my session? Maybe vice versa? I don't claim to know, but I would invite anyone who does to please answer this question with your explanation so that others may learn from my mistake.



          Removing the line kill -9 $PPID solved the problem



          If the script is executed from the *.desktop launcher, the initial gnome-terminal window will close, leaving the second. If the script is executed from the command line (for example, $ bash InitSystem), the initial gnome-terminal window does not close.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jun 5 at 3:55









          pomsky

          21.3k76494




          21.3k76494











          answered Jun 4 at 20:57









          TheIntern

          312




          312











          • I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
            – Paul Stelian
            Jun 4 at 21:27
















          • I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
            – Paul Stelian
            Jun 4 at 21:27















          I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
          – Paul Stelian
          Jun 4 at 21:27




          I think when one terminal window is closed all the processeses connected to the other end of the terminal get the SIGHUP signal, which by default terminates the process.
          – Paul Stelian
          Jun 4 at 21:27












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1043615%2fopening-desktop-file-outside-of-desktop-immediately-logs-out%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491