-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
kwin: Unwrap executable name for desktop file search #116549
Merged
samueldr
merged 1 commit into
NixOS:master
from
samueldr:fix/kwin-wayland-desktop-files
Mar 26, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
pkgs/desktops/plasma-5/kwin/0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
From 29ec6fada935ef966e5859082435ed57daa9522d Mon Sep 17 00:00:00 2001 | ||
From: Samuel Dionne-Riel <samuel@dionne-riel.com> | ||
Date: Tue, 16 Mar 2021 15:03:59 -0400 | ||
Subject: [PATCH] [NixOS] Unwrap executable name for .desktop search | ||
|
||
Why is this necessary even though -a "$0" is used in the wrapper? | ||
Because it's completely bypassing argv0! This looks at the executable | ||
file in-use according to the kernel! | ||
|
||
Wrappers cannot affect the `/proc/.../exe` symlink! | ||
--- | ||
service_utils.h | 28 +++++++++++++++++++++++++++- | ||
1 file changed, 27 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/service_utils.h b/service_utils.h | ||
index 8a70c1fad..6674f553b 100644 | ||
--- a/service_utils.h | ||
+++ b/service_utils.h | ||
@@ -26,8 +26,34 @@ namespace KWin | ||
const static QString s_waylandInterfaceName = QStringLiteral("X-KDE-Wayland-Interfaces"); | ||
const static QString s_dbusRestrictedInterfaceName = QStringLiteral("X-KDE-DBUS-Restricted-Interfaces"); | ||
|
||
-static QStringList fetchProcessServiceField(const QString &executablePath, const QString &fieldName) | ||
+static QStringList fetchProcessServiceField(const QString &in_executablePath, const QString &fieldName) | ||
{ | ||
+ // !! Start NixOS fix | ||
+ // NixOS fixes many packaging issues through "wrapper" scripts that manipulates the environment or does | ||
+ // miscellaneous trickeries and mischievous things to make the programs work. | ||
+ // In turn, programs often employs different mischievous schemes and trickeries to do *other things. | ||
+ // It often happens that they conflict. | ||
+ // Here, `kwin` tries to detect the .desktop file for a given process. | ||
+ // `kwin` followed the process `/proc/.../exe` up to the actual binary running. | ||
+ // It normally would be fine, e.g. /usr/bin/foobar is what's in the desktop file. | ||
+ // But it's not the truth here! It's extremely likely the resolved path is /nix/store/.../bin/.foobar-wrapped | ||
+ // rather than what the desktop file points to, something like /nix/store/.../bin/foobar !! | ||
+ // Since the wrappers for Nixpkgs *always* prepend a dot and append -wrapped, we assume here that we can keep | ||
+ // `/^(.*)\/\.([^/]*)-wrapped/` until the (equivalent) regex does not match. | ||
+ // This should canonicalize the wrapper name to the expected name to look for in the desktop file. | ||
+ | ||
+ // Use a copy of the const string | ||
+ QString executablePath(in_executablePath); | ||
+ | ||
+ // While the parts needed are present, "unwrap" one layer of wrapper names. | ||
+ while (executablePath.endsWith("-wrapped") && executablePath[executablePath.lastIndexOf("/")+1] == QChar('.')) { | ||
+ // Approximately equivalent to s/-wrapped$// | ||
+ executablePath.remove(executablePath.length() - 8, 8); | ||
+ // Approximately equivalent to s;/\.;/; | ||
+ executablePath.remove(executablePath.lastIndexOf("/")+1, 1); | ||
+ } | ||
+ // !! End NixOS fix | ||
+ | ||
// needed to be able to use the logging category in a header static function | ||
static QLoggingCategory KWIN_UTILS ("KWIN_UTILS", QtWarningMsg); | ||
const auto servicesFound = KApplicationTrader::query([&executablePath] (const KService::Ptr &service) { | ||
-- | ||
2.28.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think this is needed.
git format-patch
handles naming the file from the commit message. The prefix is to order patches in a group, so that e.g. patch 0002 happens after 0001, because the reverse will not necessarily apply.0001
here is fine as it is not linked to the other two patches. It can be applied before or after the other two patches.Or, let's say, let's see what the maintainer of the package thinks about that. But forcing arbitrary naming of the patch files compared to what the tooling gives is going to make it more awkward to work with.
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.
Shouldn't git name them continues when you export them all at once?
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 think @samueldr is not applying all the patches at once. I usually do
git am *.patch
when I'm working on a package. I don't have feelings about the file name. I expect it will get renamed the next time anyone works on this package's patches, and that's fine.