Skip to content

Commit eed8b3a

Browse files
flclash: use local hotkey_manager_linux
1 parent 3c9d407 commit eed8b3a

4 files changed

Lines changed: 101 additions & 35 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From fdb376d8e8189346338015eaa3e6dc6215f4ef01 Mon Sep 17 00:00:00 2001
2+
From: Dee HY <dongfengweixiao@hotmail.com>
3+
Date: Sun, 18 Jan 2026 18:12:51 +0800
4+
Subject: [PATCH] fix: early return when hotkey not found in map
5+
6+
Avoid sending events for unregistered hotkeys and passing invalid
7+
values to keybinder_unbind by returning early when lookup fails.
8+
---
9+
.../linux/hotkey_manager_linux_plugin.cc | 16 +++++++++-------
10+
1 file changed, 9 insertions(+), 7 deletions(-)
11+
12+
diff --git a/packages/hotkey_manager_linux/linux/hotkey_manager_linux_plugin.cc b/packages/hotkey_manager_linux/linux/hotkey_manager_linux_plugin.cc
13+
index 74fabe2..95fe80b 100644
14+
--- a/packages/hotkey_manager_linux/linux/hotkey_manager_linux_plugin.cc
15+
+++ b/packages/hotkey_manager_linux/linux/hotkey_manager_linux_plugin.cc
16+
@@ -32,14 +32,14 @@ G_DEFINE_TYPE(HotkeyManagerLinuxPlugin,
17+
g_object_get_type())
18+
19+
void handle_key_down(const char* keystring, void* user_data) {
20+
- const char* identifier;
21+
-
22+
std::string val = keystring;
23+
auto result = std::find_if(hotkey_id_map.begin(), hotkey_id_map.end(),
24+
[val](const auto& e) { return e.second == val; });
25+
26+
- if (result != hotkey_id_map.end())
27+
- identifier = result->first.c_str();
28+
+ if (result == hotkey_id_map.end())
29+
+ return;
30+
+
31+
+ const char* identifier = result->first.c_str();
32+
33+
g_autoptr(FlValue) event_data = fl_value_new_map();
34+
fl_value_set_string_take(event_data, "identifier",
35+
@@ -103,14 +103,16 @@ static FlMethodResponse* hkm_unregister(_HotkeyManagerLinuxPlugin* self,
36+
FlValue* args) {
37+
const char* identifier =
38+
fl_value_get_string(fl_value_lookup_string(args, "identifier"));
39+
- const char* keystring;
40+
41+
std::string val = identifier;
42+
auto result = std::find_if(hotkey_id_map.begin(), hotkey_id_map.end(),
43+
[val](const auto& e) { return e.first == val; });
44+
45+
- if (result != hotkey_id_map.end())
46+
- keystring = result->second.c_str();
47+
+ if (result == hotkey_id_map.end())
48+
+ return FL_METHOD_RESPONSE(
49+
+ fl_method_success_response_new(fl_value_new_bool(false)));
50+
+
51+
+ const char* keystring = result->second.c_str();
52+
53+
keybinder_unbind(keystring, handle_key_down);
54+
hotkey_id_map.erase(identifier);
55+
--
56+
2.53.0
57+

archlinuxcn/flclash/0002-fix-hotkey-manager.patch

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 73ad9c98c66e9549ae51e1d42cb54bda14ae2a4b Mon Sep 17 00:00:00 2001
2+
From: Dee HY <dongfengweixiao@hotmail.com>
3+
Date: Wed, 8 Apr 2026 21:49:11 +0800
4+
Subject: [PATCH] use local hotkey_manager_linux
5+
6+
---
7+
pubspec.yaml | 4 ++++
8+
1 file changed, 4 insertions(+)
9+
10+
diff --git a/pubspec.yaml b/pubspec.yaml
11+
index cca65ac..7fbe2c7 100755
12+
--- a/pubspec.yaml
13+
+++ b/pubspec.yaml
14+
@@ -82,6 +82,10 @@ dev_dependencies:
15+
16+
drift_dev: ^2.29.0
17+
18+
+dependency_overrides:
19+
+ hotkey_manager_linux:
20+
+ path: ../hotkey_manager/packages/hotkey_manager_linux
21+
+
22+
flutter:
23+
uses-material-design: true
24+
assets:
25+
--
26+
2.53.0
27+

archlinuxcn/flclash/PKGBUILD

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,36 @@ _pkgext="tar.gz"
4646
source=(
4747
"${pkgname}"::"git+https://github.com/chen08209/FlClash.git#tag=v$pkgver"
4848
"0001-fix-build-error.patch"
49-
"0002-fix-hotkey-manager.patch"
49+
"0002-fix-early-return-when-hotkey-not-found-in-map.patch"
50+
"0003-use-local-hotkey_manager.patch"
5051
"com.follow.clash.desktop"
5152
"Clash.Meta::git+https://github.com/chen08209/Clash.Meta.git"
5253
"flutter_distributor::git+https://github.com/chen08209/flutter_distributor.git"
5354
"tray_manager::git+https://github.com/chen08209/tray_manager.git"
55+
"hotkey_manager::git+https://github.com/leanflutter/hotkey_manager.git#tag=v0.2.3"
5456
)
5557
sha256sums=('aaf8c535929ecc642637334799f8396301fbc39a3ea25b2c9a8afdabf4a7e34d'
5658
'b551c46a1577758c13bdd07868d41e4de817c6184114e1b10d39e04ae572a76a'
57-
'611a118c9c0c8674db1048f53923ebff655ba8303df7a6666710bd975512f864'
59+
'b2791f04cd6d0752cc5b0746eec6b3b959def21eb21bfc3cf594deef8c8777d0'
60+
'2c1b44a63729e8882e6f1e061d018f006450403d968aafd1046b0cdf79e50d90'
5861
'0601176d0b5df7aafb3c949417b7f0d98ab17d21b6fcc89c6f83a7e031bbe45d'
5962
'SKIP'
6063
'SKIP'
61-
'SKIP')
64+
'SKIP'
65+
'5e27abd0473496b5ec7879f10b0c934d4c886a348763eb32280f2bed65d36d66')
6266

6367
prepare() {
64-
cd "$srcdir/$pkgname"
68+
cd "$srcdir/hotkey_manager"
69+
patch -p1 -i "${srcdir}/0002-fix-early-return-when-hotkey-not-found-in-map.patch"
6570

71+
cd "$srcdir/$pkgname"
6672
git submodule init
6773
git config submodule.core/Clash.Meta.url "$srcdir/Clash.Meta"
6874
git config submodule.plugins/flutter_distributor.url "$srcdir/flutter_distributor"
6975
git config submodule.plugins/tray_manager.url "$srcdir/tray_manager"
7076
git -c protocol.file.allow=always submodule update
71-
72-
export FVM_CACHE_PATH="$SRCDEST/fvm-cache"
73-
export PUB_CACHE="$SRCDEST/pub-cache"
74-
75-
fvm install 3.35.7
76-
fvm use 3.35.7
77-
fvm flutter --disable-analytics
78-
fvm flutter --no-version-check pub get
79-
8077
patch -p1 -i "${srcdir}/0001-fix-build-error.patch"
81-
patch -p1 -d "${srcdir}/$pkgname/linux/flutter/ephemeral/.plugin_symlinks/hotkey_manager_linux" -i "${srcdir}/0002-fix-hotkey-manager.patch"
78+
patch -p1 -i "${srcdir}/0003-use-local-hotkey_manager.patch"
8279

8380
# go mod download
8481
cd "$srcdir/$pkgname/core"
@@ -87,7 +84,6 @@ prepare() {
8784
}
8885

8986
build() {
90-
echo "Build: $FVM_CACHE_PATH"
9187
# build core
9288
cd "$srcdir/$pkgname/core"
9389
if [ "$CARCH" == "aarch64" ]; then
@@ -101,7 +97,13 @@ build() {
10197
export TAGS="with_gvisor"
10298
go build -tags="$TAGS" -o "../libclash/linux/FlClashCore"
10399

100+
export FVM_CACHE_PATH="$SRCDEST/fvm-cache"
104101
cd "${srcdir}/$pkgname"
102+
103+
fvm install 3.35.7
104+
fvm use 3.35.7
105+
fvm flutter --disable-analytics
106+
fvm flutter --no-version-check pub get
105107
fvm flutter build linux --release --dart-define=APP_ENV=stable
106108
}
107109

0 commit comments

Comments
 (0)