UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Add a launcher to the app drawer to run a command

    Scheduled Pinned Locked Moved General
    9 Posts 4 Posters 1.4k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • CaedemC Offline
        Caedem
        last edited by Caedem

        Perhaps you want to run a certain command often, or have a program installed that for some reason wasn't added to the app drawer. Well, if you know the command to start it, that can be fixed easily.

        You'll want to go to /home/phablet/.local/share/applications (image 1). Can't find it? Make sure you have show hidden files enabled. Here you'll see a lot of .desktop files - create a new one of the form name.desktop. Note that this is not the name you'll see in the app drawer, we'll specify that later.

        Open the file with a text editor. I can recommend Seabass2 if you don't have one yet. The first line should be:

        [Desktop Entry]
        

        Then we need to define four values: Name, Exec, Icon and Type. For example:

        Name=Discord_Libertine
        Exec=libertine-launch -i focal-3 "armcord"
        Icon=/home/phablet/Downloads/Discord.png
        Type=Application
        

        If you're unsure what type to use, try Application.
        Replace the values with what suits your usecase, of course. There are some more things you can specify if you want:

        Terminal=false
        Comment=Launch Armcord inside Libertine
        

        And so on. These have, as far as I can tell, no effect.

        And that's it! Save, refresh the app drawer by pulling down, and it should show up just fine.

        The folder where you have to make the .desktop file:
        photo_1_2024-08-14_19-18-52.jpg
        An example file:
        photo_2_2024-08-14_19-18-52.jpg
        Discord_Libertine in the app drawer:
        photo_3_2024-08-14_19-18-52.jpg

        Enthousiast. Previously used Redmi note 7, now on Fairphone 4.

        1 Reply Last reply Reply Quote 5
        • danfroD danfro referenced this topic on
        • danfroD Offline
          danfro
          last edited by

          I actually had to add the line with "Type=Application" before the script launcher would show up in the launcher. But it seems not to work for commands needing sudo.

          arubislanderA CaedemC 2 Replies Last reply Reply Quote 0
          • arubislanderA Online
            arubislander @danfro
            last edited by

            @danfro try pkexec instead of sudo.

            πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
            Happily running Ubuntu Touch
            Google Pixel 3a (20.04 DEV)
            JingPad (24.04 preview)
            Meizu Pro 5 (16.04 DEV)

            danfroD 1 Reply Last reply Reply Quote 0
            • arubislanderA arubislander moved this topic from Off topic on
            • danfroD Offline
              danfro @arubislander
              last edited by danfro

              @arubislander Thanks for that suggestion. But it does not seem to help.

              i have Exex= pkexec systemctl restart ofono.service but get this error:

              [08.11.24 08:21] Error creating textual authentication agent: Error opening current controlling terminal for the process (`/dev/tty'): No such device or address

              I can use this line of code fine in terminal sudo -S <<< "mypassword" systemctl restart ofono.service. But running it from that desktop file brings this error:

              [08.11.24 08:30] [sudo] password for phablet:
              [08.11.24 08:30] sudo: no password was provided
              [08.11.24 08:30] pam_extrausers(sudo:auth): conversation failed
              [08.11.24 08:30] pam_extrausers(sudo:auth): auth could not identify password for [phablet]
              

              It doesn't matter if terminal is set to true or false in the desktop file.

              arubislanderA 1 Reply Last reply Reply Quote 0
              • arubislanderA Online
                arubislander @danfro
                last edited by

                @danfro said in Add a launcher to the app drawer to run a command:

                i have Exex= pkexec systemctl restart ofono.service but get this error:

                When you perform that command in the terminal, you don't get a window pop up with a password prompt?

                πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
                Happily running Ubuntu Touch
                Google Pixel 3a (20.04 DEV)
                JingPad (24.04 preview)
                Meizu Pro 5 (16.04 DEV)

                danfroD 1 Reply Last reply Reply Quote 0
                • danfroD Offline
                  danfro @arubislander
                  last edited by

                  @arubislander not a popup, but some terminal output asking for the password. But even in terminal I get a authentication failed (Error executing command as another user: not authorized) error. With sudo at least it works in terminal, just not when using the desktop icon to exec the command.

                  arubislanderA 1 Reply Last reply Reply Quote 0
                  • arubislanderA Online
                    arubislander @danfro
                    last edited by

                    @danfro I have enclosed an example of what I get.

                    screen_recording_2024_11_08__12_07_02_879.gif

                    Maybe it is because I have snaps enabled on my device.

                    πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
                    Happily running Ubuntu Touch
                    Google Pixel 3a (20.04 DEV)
                    JingPad (24.04 preview)
                    Meizu Pro 5 (16.04 DEV)

                    K 1 Reply Last reply Reply Quote 0
                    • K Offline
                      kristatos @arubislander
                      last edited by

                      @arubislander For me it's the same authentication failure like @danfro The GUI which comes up in your example isn't there for me. You have to enter the password in the same terminal-window where you have entered the command. (Vollaphone, UT 20.04 devel)

                      BQ Aquaris E4.5 (UT 16.04)
                      Vollaphone (UT 20.04)

                      1 Reply Last reply Reply Quote 0
                      • CaedemC Offline
                        Caedem @danfro
                        last edited by

                        @danfro said in Add a launcher to the app drawer to run a command:

                        I actually had to add the line with "Type=Application" before the script launcher would show up in the launcher..

                        I'll move it to the top part then, thanks for the feedback!

                        Enthousiast. Previously used Redmi note 7, now on Fairphone 4.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post