NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.39k stars 13.61k forks source link

gnomeExtensions.pop-shell: Keyboard shortcuts aren’t listed in settings #314969

Open AndrewKvalheim opened 3 months ago

AndrewKvalheim commented 3 months ago

Describe the bug

Pop Shell reportedly defines keyboard shortcuts that can be configured via GNOME’s settings, but they are missing.

Steps To Reproduce

  1. Enable gnomeExtensions.pop-shell and re–log in.
  2. View SettingsKeyboardView and Customize Shortcuts.

Expected behavior

The available keyboard shortcuts include Move, resize, and swap windowsMove window left outside management mode.

Additional context

I can see the keyboard shortcuts listed in the Pop Shell source but I’m not sure how to make GNOME use them.

Notify maintainers

@genofire

Metadata

$ nix-info --markdown
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.91, NixOS, 23.11 (Tapir), 23.11.7237.46397778ef1f`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nix-math, nixos-23.11, nixos-hardware"`
 - channels(ak): `"community-vscode-extensions, home-manager-23.11.tar.gz, nix-colors, rust-overlay, unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

AndrewKvalheim commented 3 months ago

Working around #92265 and linking keybindings makes it work:

gnomeExtensions = pkgs.gnomeExtensions // {
  pop-shell = pkgs.gnomeExtensions.pop-shell.overrideAttrs (p: {
    postInstall = p.postInstall or "" + ''
      # Workaround for NixOS/nixpkgs#92265
      mkdir --parents "$out/share/gsettings-schemas/$name/glib-2.0"
      ln --symbolic "$out/share/gnome-shell/extensions/pop-shell@system76.com/schemas" "$out/share/gsettings-schemas/$name/glib-2.0/schemas"

      # Workaround for NixOS/nixpkgs#314969
      mkdir --parents "$out/share/gnome-control-center"
      ln --symbolic "$src/keybindings" "$out/share/gnome-control-center/keybindings"
    '';
  });
};
# Workaround for NixOS/nixpkgs#92265
services.xserver.desktopManager.gnome.sessionPath = [ pkgs.gnomeExtensions.pop-shell ];

screenshot of Keyboard Shortcuts screen

genofire commented 2 months ago

so should we but it to this extension? @AndrewKvalheim do you like to create a PR?

Or is it a failure in nixos and gnome and this should be solved anywhere else like #92265 (and we could close this issue)

jzw2 commented 2 months ago

I've tried the above workaround, however, it now crashes for some reason when I try to open the keyboard shortcuts. The jounal log shows that it still does not find the schema right before it crashes.

AndrewKvalheim commented 2 months ago

@AndrewKvalheim do you like to create a PR?

No, I’m not sure how to correctly package this and I personally don’t use Pop Shell. Just sharing what I discovered in case that helps anyone.

cochaviz commented 3 weeks ago

I've tried the above workaround, however, it now crashes for some reason when I try to open the keyboard shortcuts. The jounal log shows that it still does not find the schema right before it crashes.

Just wanted to let others know that I'm also facing the same issue. Furthermore, not all the shortcuts are applied either, some are still overridden by the default behavior such as Ctrl+H for hiding a window.

Trying to find a fix, but I have been using NixOS for only a couple of days, so it might take a while 😅

vec715 commented 2 weeks ago

I have the same issue

cochaviz commented 2 weeks ago

So what I have now works pretty reliably, but I'm not sure whether this is the most appropriate method of fixing this. Personally, I have a hard time understanding the interactions of gsettings and NixOS, so I've resorted to hard-coding the keybindings with dconf:

# pop-shell-keybindings.nix

{
  "org/gnome/desktop/wm/keybindings" = {
    close = ["<Super>q" "<Alt>F4"];
    minimize = ["<Super>comma"];
    toggle-maximized = ["<Super>m"];
    move-to-monitor-left = [];
    move-to-monitor-right = [];
    move-to-monitor-up = [];
    move-to-monitor-down = [];
    move-to-workspace-down = [];
    move-to-workspace-up = [];
    switch-to-workspace-down = ["<Primary><Super>Down"];
    switch-to-workspace-up = ["<Primary><Super>Up"];
    switch-to-workspace-left = [];
    switch-to-workspace-right = [];
    maximize = [];
    unmaximize = [];
  };

  "org/gnome/shell/keybindings" = {
    open-application-menu = [];
    toggle-message-tray = ["<Super>v"];
    toggle-overview = [];
  };

  "org/gnome/mutter/keybindings" = {
    toggle-tiled-left = [];
    toggle-tiled-right = [];
  };

  "org/gnome/mutter/wayland/keybindings" = {
    restore-shortcuts = [];
  };

  "org/gnome/settings-daemon/plugins/media-keys" = {
    screensaver = ["<Super>Escape"];
    home = ["<Super>f"];
    www = ["<Super>b"];
    terminal = ["<Super>t"];
    email = ["<Super>e"];
    rotate-video-lock-static = [];
  };

  "org/gnome/shell/extensions/pop-shell" = {
    toggle-tiling = ["<Super>y"];
    toggle-floating = ["<Super>g"];
    tile-enter = ["<Super>Return"];
    tile-accept = ["Return"];
    tile-reject = ["Escape"];
    toggle-stacking-global = ["<Super>s"];
    pop-workspace-down = ["<Shift><Super>Down" "<Shift><Super>j"];
    pop-workspace-up = ["<Shift><Super>Up" "<Shift><Super>k"];
    pop-monitor-left = ["<Shift><Super>Left" "<Shift><Super>h"];
    pop-monitor-right = ["<Shift><Super>Right" "<Shift><Super>l"];
    pop-monitor-down = [];
    pop-monitor-up = [];
    focus-left = ["<Super>Left" "<Super>h"];
    focus-down = ["<Super>Down" "<Super>j"];
    focus-up = ["<Super>Up" "<Super>k"];
    focus-right = ["<Super>Right" "<Super>l"];
  };
}

I also have custom keybindings, which is why I put them in a separate file, and then combine them like this:

# gnome.nix

{ config, lib, pkgs, ... }:

let
  popOsKeybindings = import ./pop-os-keybindings.nix;
  # customKeyBindings = import ./custom-keybindings.nix;
in
  {
    dconf.settings =
      popOsKeybindings;
      # // customKeybindings
  }

NOTE: To set keybindings (especially custom keybindings), make sure that there are no conflicting bindings. You can check whether any are set using, for example, gsettings list-recursively | grep "<Super><1>".

I'm not sure how to integrate this into the package, but I thought to put this here first so people can still use it. You have to make sure that you delete any current keybindings you have. Ideally you would have them defined declaratively anyway.

Personally, I don't think this is the 'ideal' way of solving this, as we are now hard-coding their keybindings. If they change, we have to change the package. But declaring the keybindings like this does seem a more 'nix-ian' approach, and it is definitely more readable/hackable. ~Another thing that's not great is that, at least in my case, I need the --impure flag to be able to find the files.~

EDIT: Just using // doesn't work. If you have custom keybindings that you would like to have applied, make sure to use lib.recursiveUpdate customKeybindings popOsKeybindings. This merges the sets in the sets, and ensures that the popOsKeybindings are always present. If you would like your own keybindings to override others, just switch the arguments around.