-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can try to change Exec to echo $PATH > /tmp/path_out
and execute again to get more info for debugging.
There was a problem hiding this comment.
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.
If you add this code as This is the one I used for the Windows version of guiscrcpy Hope it helps.. |
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. |
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 <[email protected]> Signed-off-by: Romain Vimont <[email protected]>
Make Exec= compatible with $PATH configured in .bashrc/ or .zshrc/… PR #3351 <#3351> Refs #296 <#296 (comment)> Signed-off-by: Romain Vimont <[email protected]>
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 <[email protected]> Signed-off-by: Romain Vimont <[email protected]>
Make Exec= compatible with $PATH configured in .bashrc/ or .zshrc/… PR #3351 <#3351> Refs #296 <#296 (comment)> Signed-off-by: Romain Vimont <[email protected]>
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 <[email protected]> Signed-off-by: Romain Vimont <[email protected]>
Make Exec= compatible with $PATH configured in .bashrc or .zshrc… PR #3351 <#3351> Refs #296 <#296 (comment)> Signed-off-by: Romain Vimont <[email protected]>
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 <[email protected]> Signed-off-by: Romain Vimont <[email protected]>
Make Exec= compatible with $PATH configured in .bashrc or .zshrc… PR #3351 <#3351> Refs #296 <#296 (comment)> Signed-off-by: Romain Vimont <[email protected]>
Closed with #3351 |
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