Skip to content

Commit df43c94

Browse files
authored
feat(shortcuts): add option to disable the default super key action
1 parent 2705479 commit df43c94

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cosmic-settings/src/pages/desktop/window_management.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl Default for Page {
5454
fl!("super-key", "launcher"),
5555
fl!("super-key", "workspaces"),
5656
fl!("super-key", "applications"),
57+
fl!("super-key", "disable"),
5758
],
5859
super_key_active: super_key_active_config(),
5960
comp_config,
@@ -68,9 +69,10 @@ impl Page {
6869
match message {
6970
Message::SuperKey(id) => {
7071
let action = match id {
71-
0 => shortcuts::action::System::Launcher,
72-
1 => shortcuts::action::System::WorkspaceOverview,
73-
2 => shortcuts::action::System::AppLibrary,
72+
0 => Some(shortcuts::action::System::Launcher),
73+
1 => Some(shortcuts::action::System::WorkspaceOverview),
74+
2 => Some(shortcuts::action::System::AppLibrary),
75+
3 => None,
7476
_ => return,
7577
};
7678

@@ -131,6 +133,7 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
131133
let _launcher = descriptions.insert(fl!("super-key", "launcher"));
132134
let _workspaces = descriptions.insert(fl!("super-key", "workspaces"));
133135
let _applications = descriptions.insert(fl!("super-key", "applications"));
136+
let _disable = descriptions.insert(fl!("super-key", "disable"));
134137

135138
Section::default()
136139
.descriptions(descriptions)
@@ -240,16 +243,17 @@ fn super_key_active_config() -> Option<usize> {
240243
new_id
241244
}
242245

243-
fn super_key_set(action: shortcuts::action::System) {
246+
fn super_key_set(action: Option<shortcuts::action::System>) {
244247
let Ok(config) = shortcuts::context() else {
245248
return;
246249
};
247250

248251
let mut shortcuts = config.get::<Shortcuts>("custom").unwrap_or_default();
252+
let action = action.map(Action::System).unwrap_or(Action::Disable);
249253

250254
shortcuts.0.insert(
251255
Binding::new(shortcuts::Modifiers::new().logo(), None),
252-
Action::System(action),
256+
action,
253257
);
254258

255259
_ = config.set("custom", &shortcuts);

i18n/en/cosmic_settings.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ dock = Dock
173173
window-management = Window management
174174
.desc = Super key action, window control options, and additional window tiling options.
175175
176-
super-key = Super key
176+
super-key = Super key action
177177
.launcher = Open Launcher
178178
.workspaces = Open Workspaces
179179
.applications = Open Applications
180+
.disable = Disable
180181
181182
window-controls = Window Controls
182183
.maximize = Show maximize button

0 commit comments

Comments
 (0)