Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop entry file for Linux app launchers (resolves #295) #296

Closed
wants to merge 1 commit into from

Conversation

asnelling
Copy link
Contributor

Adds the ability to launch scrcpy using your preferred application launcher on Linux.

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

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

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

Cool 👍 Comments inline.

One small drawback is that scrcpy uses the terminal to output info and error, and there is no terminal when started from the menu (but it's like on Windows then).

@@ -143,6 +143,12 @@ endif

executable('scrcpy', src, dependencies: dependencies, include_directories: src_dir, install: true, c_args: c_args, link_args: link_args)

# Desktop entry file for application launchers
if host_machine.system() == 'linux'
# -> /usr/share/applications/scrcpy.desktop
Copy link
Collaborator

Choose a reason for hiding this comment

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

(by default /usr/local/share/applications/scrcpy.desktop, but you can keep this comment as is, it's explicit enough)

GenericName=Android Remote Control
Comment=Display and control your Android device
Exec=scrcpy
Icon=gparted
Copy link
Collaborator

Choose a reason for hiding this comment

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

scrcpy

gparted icon does not really fit scrcpy. Unfortunately, I didn't find any existing icon that could fit. Maybe we should add an Android icon?

Choose a reason for hiding this comment

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

You can use this icon guiscrcpy, which I created for guiscrcpy. I licensed it under Creative Commons Attributions 4.0, so you can easily reuse it.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Android icon at https://github.com/Genymobile/scrcpy/blob/v1.18/app/src/icon.xpm may be a better choice. Here is an improved patch:

diff --git a/app/meson.build b/app/meson.build
index 0663c64..321ed38 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -148,6 +148,14 @@ executable('scrcpy', src,
 
 install_man('scrcpy.1')
 
+# Desktop entry file for application launchers
+if host_machine.system() == 'linux'
+    # -> /usr/share/applications/scrcpy.desktop
+    install_data('scrcpy.desktop', install_dir : join_paths(get_option('datadir'), 'applications'))
+    install_data('src/icon.xpm', rename: 'scrcpy.xpm',
+                 install_dir : join_paths(get_option('datadir'), 'icons', 'hicolor', '48x48', 'apps'))
+endif
+
 
 ### TESTS
 
diff --git a/app/scrcpy.desktop b/app/scrcpy.desktop
new file mode 100644
index 0000000..5933272
--- /dev/null
+++ b/app/scrcpy.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=scrcpy
+GenericName=Android Remote Control
+Comment=Display and control your Android device
+Exec=scrcpy
+Icon=scrcpy
+Terminal=false
+Type=Application
+Categories=Utility;RemoteAccess;
+StartupNotify=false

Name=scrcpy
GenericName=Android Remote Control
Comment=Display and control your Android device
Exec=scrcpy
Copy link
Collaborator

@rom1v rom1v Oct 14, 2018

Choose a reason for hiding this comment

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

At first, it did not work for me.

To get the error, I changed to:

Exec=bash -c "scrcpy &> /tmp/log"

And /tmp/log contained:

exec: No such file or directory
ERROR: 'adb' command not found (make it accessible from your PATH or define its full path in the ADB environment variable)
ERROR: Could not execute "adb push"

In fact, the adb directory is added in PATH in my .bashrc, so it's not in PATH when the session is started, so starting it for the menu does not work in that case.

In practice, do you use the android-tools-adb package, or did you put your adb directory in PATH from somewhere else?

Copy link
Contributor

@npes87184 npes87184 Jan 19, 2019

Choose a reason for hiding this comment

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

I add the file in /usr/share/applications/scrcpy.desktop with content:

[Desktop Entry]
Name=scrcpy
GenericName=Android Remote Control
Comment=Display and control your Android device
Exec=scrcpy
Icon=gparted
Terminal=false
Type=Application
Categories=Utility;RemoteAccess;
StartupNotify=false

After it, click the icon from menu. Scrcpy starts as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rom1v

Maybe you can try to change Exec to echo $PATH > /tmp/path_out and execute again to get more info for debugging.

Copy link
Contributor

@yan12125 yan12125 Jun 21, 2021

Choose a reason for hiding this comment

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

I guess bash -i -c scrcpy will work for adb not in standard paths? That bash option forces the interactive mode and .bashrc is sourced. I use android-tools on Arch Linux, where adb is installed under /usr/bin, so I cannot test my idea.

@srevinsaju
Copy link

If you add this code as scrcpy.VisualElements.xml, you can get that customized Windows Start Menu Effect, as you see for OneNote Tiles etc..

This is the one I used for the Windows version of guiscrcpy
<?xml version="1.0" encoding="utf-8"?> <Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <VisualElements ShowNameOnSquare150x150Logo="off" Square150x150Logo="VisualElements\MediumIconguiscrcpy.png" Square70x70Logo="VisualElements\SmallIconguiscrcpy.png" ForegroundText="light" BackgroundColor="#00FED0" />

Hope it helps..

@unclehowell
Copy link

In my experience its better to have the .Desktop run a script which resets network adaptors and establishes connection with the android first. In the script the correct screen size and connection speed can be set and appropriate sleep times between commands

@yan12125
Copy link
Contributor

In my experience its better to have the .Desktop run a script which resets network adaptors and establishes connection with the android first. In the script the correct screen size and connection speed can be set and appropriate sleep times between commands

Hmm, scrcpy runs adb, which connects to the Android device when needed. Is there a reason to reset network adaptors? Anyway, if some preparation steps are needed, they are better to be part of the scrcpy command instead of the .desktop file, so that those who run scrcpy from the terminal can benefit from it as well.

rom1v pushed a commit that referenced this pull request Jun 27, 2022
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 <[email protected]>
rom1v pushed a commit that referenced this pull request Jun 27, 2022
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 <[email protected]>
rom1v pushed a commit that referenced this pull request Aug 29, 2022
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 <[email protected]>
rom1v pushed a commit that referenced this pull request Sep 9, 2022
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 <[email protected]>
@asnelling
Copy link
Contributor Author

Closed with #3351

@asnelling asnelling closed this Sep 9, 2022
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.

6 participants