Skip to content

Desktop entry file for Linux app launchers #295 - #3351

Closed
yan12125 wants to merge 4 commits into
Genymobile:masterfrom
yan12125:desktop-entry
Closed

yan12125 wants to merge 4 commits into
Genymobile:masterfrom
yan12125:desktop-entry

Conversation

@yan12125

Copy link
Copy Markdown

See: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

  • Address review comments

Seems #296 is stale, so I created a replacement with fixes. Differences from the previous pull request are in the second commit.

rom1v pushed a commit that referenced this pull request Jun 27, 2022
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html>

PR #3351 <#3351>
Replaces PR #296 <#296>
Fixes #295 <#295>
Fixes #748 <#748>
Fixes #1636 <#1636>

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Jun 27, 2022
Make Exec= compatible with $PATH configured in .bashrc/ or .zshrc/â€Ķ

PR #3351 <#3351>
Refs #296 <#296 (comment)>

Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v

rom1v commented Jun 27, 2022 •

Copy link
Copy Markdown
Collaborator

Hi,

Thank you 👍

I added a first commit to replace the hardcoded share/ in meson.build by the datadir variable (on dev branch). Then I rebased/re-split the commits.

Then I added a scrcpy-console.desktop to provide a launcher with a terminal (like scrcpy-console.bat).

The resulting branch is here: pr3351

Please review and test 😉

@yan12125

Copy link
Copy Markdown
Author

Awesome improvements! Just one minor suggestion -

For some users, adb is not in default $PATH but the one configured in .bashrc/ or .zshrc/...

"or" indeed makes it clearer, but a slash after .bashrc is somewhat unusual. Probably better with

For some users, adb is not in default $PATH but the one configured in .bashrc, .zshrc, or other shell startup scripts.

(Term "shell startup scripts" is just the first one out of my head. Different people use different terms for those files :D)

scrcpy.desktop works as usual. For scrcpy-console.desktop, the "complex" Exec= line hits some other software. I'm using QTerminal on LXQt, where lxqt/qterminal#961 is needed to correctly parse that line. That's a QTerminal bug, so keeping the current scrcpy-console.desktop is fine.

rom1v added a commit that referenced this pull request Jun 27, 2022
Meson defines a variable for the data directory.

PR #3351 <#3351>
rom1v pushed a commit that referenced this pull request Jun 27, 2022
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html>

PR #3351 <#3351>
Replaces PR #296 <#296>
Fixes #295 <#295>
Fixes #748 <#748>
Fixes #1636 <#1636>

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Jun 27, 2022
Make Exec= compatible with $PATH configured in .bashrc/ or .zshrc/â€Ķ

PR #3351 <#3351>
Refs #296 <#296 (comment)>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v added a commit that referenced this pull request Jun 27, 2022
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).

The behavior is the same as scrcpy-console.bat on Windows.

PR #3351 <#3351>
rom1v added a commit that referenced this pull request Jun 27, 2022
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).

The behavior is the same as scrcpy-console.bat on Windows.

PR #3351 <#3351>
@rom1v

rom1v commented Jun 27, 2022

Copy link
Copy Markdown
Collaborator

(Term "shell startup scripts" is just the first one out of my head. Different people use different terms for those files :D)

In man bash:

       ~/.bashrc
              The individual per-interactive-shell startup file

So "shell startup script" looks good to me.

For some users, adb is not in default $PATH but the one configured in .bashrc, .zshrc, or other shell startup scripts.

I suggest:

+# For some users, the PATH or ADB environment variables are set from the shell
+# startup file, like .bashrc or .zshrcâ€Ķ Run an interactive shell to get
+# environment correctly initialized.

What do you think? See pr3351.2.

For scrcpy-console.desktop, the "complex" Exec= line hits some other software. I'm using QTerminal on LXQt, where lxqt/qterminal#961 is needed to correctly parse that line.

😞

That's a QTerminal bug, so keeping the current scrcpy-console.desktop is fine.

OK

@yan12125

Copy link
Copy Markdown
Author

Looks great, thank you very much for the efforts!

@rom1v

rom1v commented Jun 28, 2022

Copy link
Copy Markdown
Collaborator

@asnelling as the author of #296, any remark?

Comment thread app/scrcpy.desktop Outdated
Comment on lines +5 to +7
# For some users, `adb` is not in default $PATH but the one configured in .bashrc/.zshrc/...
# Run an interactive shell to get the same path used in terminals.
Exec=/bin/sh -c '"$SHELL" -i -c scrcpy'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For system-wide installations, Exec should use the system-wide adb installed at, e.g.: /usr/bin/adb and leave customization concerns up to the user in e.g.: ~/.local/applications/scrcpy.desktop
👍 good to merge

@asnelling

Copy link
Copy Markdown
Contributor

IMO, Exec= should let the system resolve scrcpy and not invoke a shell. Users customizations belong in ~/.local/share/applications/scrcpy.desktop . It seems the convention (at least in Ubuntu) is Exec=scrcpy or Exec=/usr/bin/scrcpy, which you can see with:

$ grep '^Exec=' /usr/share/applications/*.desktop

More importantly, merge it 👍

@yan12125

Copy link
Copy Markdown
Author

For system-wide installations, Exec should use the system-wide adb installed at, e.g.: /usr/bin/adb

It's up to whether rom1v wants to support $PATH or $ADB configured in .bashrc/.zshrc/... or not. I'm fine with either.

It seems the convention (at least in Ubuntu) is Exec=scrcpy or Exec=/usr/bin/scrcpy

It's also possible to extract those "complex" Exec= lines to standalone scripts like /usr/bin/scrcpy-console.sh and /usr/bin/scrcpy-noconsole.sh, and use them in Exec=.

@rom1v

rom1v commented Jun 29, 2022

Copy link
Copy Markdown
Collaborator

IMO, Exec= should let the system resolve scrcpy and not invoke a shell.

So, for the non-console version:

Exec=/usr/bin/scrcpy

For the console version:

Exec=/usr/bin/scrcpy || bash -i -c 'read -p "Press any key to quit..."'

?

Where should the user define ADB or PATH so that it is used for the launcher in that case?

@yangfl any opinion about the content of Exec=?

@yangfl

yangfl commented Jun 30, 2022 •

Copy link
Copy Markdown
Contributor

I think you can't use the shell syntax in Exec=.

"$SHELL" -i -c scrcpy

Strange, but acceptable as long as the software author satisfies with it.

@yan12125

yan12125 commented Jul 1, 2022 •

Copy link
Copy Markdown
Author

Exec=/usr/bin/scrcpy || bash -i -c 'read -p "Press any key to quit..."'

I think you can't use the shell syntax in Exec=.

Yeah, || is passed as an argument and failed. Here is a working example with waiting and no interactive shell:

Exec=/bin/bash -c 'scrcpy || read -p "Press any key to quit..."'

"$SHELL" -i -c scrcpy
Strange, but acceptable as long as the software author satisfies with it.

I checked and found that qterminal and similar programs expand environment variables. I'm not sure if other terminal emulators do that or not.

Where should the user define ADB or PATH so that it is used for the launcher in that case?

That depends on how an X11 or Wayland session is started. Apparently there is no universal way - see https://wiki.archlinux.org/title/Environment_variables#Graphical_environment

@rom1v

rom1v commented Jul 1, 2022

Copy link
Copy Markdown
Collaborator

Yeah, || is passed as an argument and failed. Here is a working example with waiting and no interactive shell:

Exec=/bin/bash -c 'scrcpy || read -p "Press any key to quit..."'

OK. But then the scrcpy-console version will load environment variables from .bashrc (whatever the default shell), while the non-console version will not.

"$SHELL" -i -c scrcpy

Strange, but acceptable as long as the software author satisfies with it.

OK, so maybe I will keep pr3351.2.

Thank you.

@yan12125

yan12125 commented Jul 1, 2022

Copy link
Copy Markdown
Author

But then the scrcpy-console version will load environment variables from .bashrc (whatever the default shell), while the non-console version will not.

Yeah that's an issue. How about /bin/bash --norc --noprofile ...?

rom1v and others added 4 commits July 9, 2022 02:56
Meson defines a variable for the data directory.

PR #3351 <#3351>
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html>

PR #3351 <#3351>
Replaces PR #296 <#296>
Fixes #295 <#295>
Fixes #748 <#748>
Fixes #1636 <#1636>

Co-authored-by: Addison Snelling <addison@asnell.io>
Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
Make Exec= compatible with $PATH configured in .bashrc/ or .zshrc/â€Ķ

PR #3351 <#3351>
Refs #296 <#296 (comment)>

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).

The behavior is the same as scrcpy-console.bat on Windows.

PR #3351 <#3351>
@yan12125

yan12125 commented Jul 8, 2022

Copy link
Copy Markdown
Author

How about /bin/bash --norc --noprofile ...?

Assuming no objection for this approach, I imported pr3351.2 branch, added proposed bash arguments and force-updated this PR.

rom1v added a commit that referenced this pull request Aug 29, 2022
Meson defines a variable for the data directory.

PR #3351 <#3351>
rom1v pushed a commit that referenced this pull request Aug 29, 2022
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html>

PR #3351 <#3351>
Replaces PR #296 <#296>
Fixes #295 <#295>
Fixes #748 <#748>
Fixes #1636 <#1636>

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Aug 29, 2022
Make Exec= compatible with $PATH configured in .bashrc or .zshrcâ€Ķ

PR #3351 <#3351>
Refs #296 <#296 (comment)>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v added a commit that referenced this pull request Aug 29, 2022
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).

The behavior is the same as scrcpy-console.bat on Windows.

PR #3351 <#3351>
rom1v added a commit that referenced this pull request Sep 9, 2022
Meson defines a variable for the data directory.

PR #3351 <#3351>
rom1v pushed a commit that referenced this pull request Sep 9, 2022
Refs <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html>

PR #3351 <#3351>
Replaces PR #296 <#296>
Fixes #295 <#295>
Fixes #748 <#748>
Fixes #1636 <#1636>

Co-authored-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Sep 9, 2022
Make Exec= compatible with $PATH configured in .bashrc or .zshrcâ€Ķ

PR #3351 <#3351>
Refs #296 <#296 (comment)>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v added a commit that referenced this pull request Sep 9, 2022
Add a launcher which opens a terminal, and keep it open in case of
errors (so that the user has time to read error messages).

The behavior is the same as scrcpy-console.bat on Windows.

PR #3351 <#3351>
@rom1v

rom1v commented Sep 9, 2022

Copy link
Copy Markdown
Collaborator

Merged into dev.

@yan12125

Copy link
Copy Markdown
Author

Thanks!

@kidonng kidonng mentioned this pull request Nov 21, 2023
Linux4 pushed a commit to Linux4/scrcpy that referenced this pull request Sep 5, 2025
scrcpy v1.25

Changes since v1.24:
 - Adapt copy-paste internals for Android 13 (Genymobile#3497)
 - Add support for high-precision scrolling (Genymobile#3363, Genymobile#3369)
 - Add desktop entry files for Linux (Genymobile#295, Genymobile#296, Genymobile#748, Genymobile#1636, Genymobile#3351)
 - Add bash and zsh autocompletion for -s/--serial (Genymobile#3522, Genymobile#3523)
 - Use current adb port (if any) for --tcpip (Genymobile#3591, Genymobile#3592)
 - Add fallback to get display information on some devices (Genymobile#3416, Genymobile#3573)
 - Fix click behavior when --forward-all-clicks is set (Genymobile#3568, Genymobile#3579)
 - Fix support for non-ASCII characters in window title (Genymobile#2932, Genymobile#3547)
 - Fix getDisplayIds() crash on some versions of Android 13 beta (Genymobile#3446)
 - Upgrade platform-tools to 33.0.3 (adb) in Windows releases
 - Upgrade FFmpeg to 5.1.2 in Windows 64-bit releases
 - Upgrade SDL to 2.26.1 in Windows releases
 - Various technical fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants