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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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)

install_data('scrcpy.desktop', install_dir : join_paths(get_option('datadir'), 'applications'))
endif


### TESTS

Expand Down
10 changes: 10 additions & 0 deletions app/scrcpy.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
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.

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

Terminal=false
Type=Application
Categories=Utility;RemoteAccess;
StartupNotify=false