Announcement

Collapse
No announcement yet.

Problem with Automatically Opening a Text File in Kwrite After KDE Login

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with Automatically Opening a Text File in Kwrite After KDE Login

    My Goal
    I'd like to automatically open a text file in Kwrite, after logging into KDE. (The text file contains a list of tasks I want to preform each day.)


    My Attempt
    1. I checked online and learned that I could write a simple Bash shell script to open a text file on login.
    2. I followed some instructions and created the following shell script.
    3. I named the Bash shell script as "task_test.sh"
    4. I opened the KDE "Autostart" program, clicked on "Add Script", chose the "task_test.sh" file and clicked "OK"

    Code:
    #!/bin/bash
    xdg-open "/home/username/tasks.txt"
    (Note: I changed my real username to "username" above, for privacy reasons)


    My Problem
    1. I logged in and out of KDE and saw Kwrite loading in the KDE "Task Manager" Plasmoid in my KDE Plasma Panel.
    2. Eventually I noticed that the usual KDE applications weren't loading. (ex: Kmix, KDE Network Manager, etc)
    3. After some time passed, I realized that KDE had frozen.
    4. I used the keyboard combination of [Ctrl] + [Shift] + [F1] to switch into a BusyBox terminal.
    5. I used the "Nano" text editor to remove the "task_test.sh" file from ~/.kde/Autostart
    6. When I logged in and out, KDE was able to start normally, without freezing.
    7. I again tried logging in and out of KDE and saw no problems loading KDE.
    8. I used the KDE Autostart program again, to try and add the same script.
    9. After I logged in and out of KDE, the freezing problem reappeared.
    10. I had to remove the "task_test.sh" file from ~/.kde/Autostart again, to stop KDE from freezing on login.



    My Questions

    • Why would my simple Bash script cause KDE to freeze?
      • Did I make a typo somewhere in the Bash script?

    • Is there a better way to automatically open a text file in Kwrite, after login?




    Thanks for reading.

    #2
    Curious as to why using xdg-open instead of just kwrite, but either should work I think.

    Are the permissions and ownership correct on your script?

    Please Read Me

    Comment


      #3
      Originally posted by oshunluvr View Post
      Curious as to why using xdg-open instead of just kwrite, but either should work I think.
      I originally created the Bash script with "kwrite" and noticed the same freezing problem when logging in to KDE. So I tried "xdg-open" instead, after I read that it's the generic command for opening an application in a Bash shell script. I wanted to see if using a generic command in my Bash shell script would stop the KDE freezing problem.

      But unfortunately both commands had the same KDE freezing problem.



      Originally posted by oshunluvr View Post
      Are the permissions and ownership correct on your script?
      Thanks for the suggestion. I noticed just now that I didn't give the Bash shell script permission to be executable.

      With the new file permission, I was successfully able to use the Bash shell script to automatically open the text file, after logging in to KDE. Thanks a lot for your help!

      Comment


        #4
        Easy!

        Although, I'm surprised this caused a "freeze" of your desktop. Probably if you did it correctly - which means creating a .desktop file to launch the script rather than attempting it directly - it would have worked properly - as in failed without locking up the desktop.

        Just guessing here, but I suspect since you attempted to launch a program from the GUI without a "connection" to the desktop, the error message re. permissions just sat and held up the continuation of your desktop launching.

        Whatever - at least you have it working and hopefully you'll remember this command next time: chmod +x <your.script.here>

        Please Read Me

        Comment


          #5
          BTW, probably going to the terminal and killing the script would have allowed your desktop to continue loading rather than deleting and logging in/out etc.

          Please Read Me

          Comment


            #6
            Originally posted by oshunluvr View Post
            Easy!

            Although, I'm surprised this caused a "freeze" of your desktop. Probably if you did it correctly - which means creating a .desktop file to launch the script rather than attempting it directly - it would have worked properly - as in failed without locking up the desktop.
            Oh, I see. I didn't realize that creating a .desktop file would have allowed the script to fail without freezing my desktop. Thanks for the advice.


            Originally posted by oshunluvr View Post
            Just guessing here, but I suspect since you attempted to launch a program from the GUI without a "connection" to the desktop, the error message re. permissions just sat and held up the continuation of your desktop launching.
            Yes, once I discovered that the problem was being caused by a file permissions issue, I realized that the freezing was likely caused by KDE waiting for the proper permission before it continued loading the KDE desktop.


            Originally posted by oshunluvr View Post
            Whatever - at least you have it working and hopefully you'll remember this command next time: chmod +x <your.script.here>
            Thanks for sharing that permissions command.


            Originally posted by oshunluvr View Post
            BTW, probably going to the terminal and killing the script would have allowed your desktop to continue loading rather than deleting and logging in/out etc.
            Yes, I realized that I could have used a terminal command to kill the Bash shell script.

            But the reason I removed the script from my "Autostart" directory, was because I wanted to be able to stop the freezing problem for future KDE logins, because I had to get other work done. Then, when I had more time in the future, I could continue testing different Bash shell script ideas.


            Details aside, I am now able to open the text file automatically, without freezing the KDE desktop. So thanks again for your help.

            Comment

            Working...
            X