Running xmodmap at startup

The plan is to avoid runing xmodmap ~/.Xmodmap in the terminal every time I reboot. I have seriously tried it all: creating a new service with systemd, running through all sorts of different options including full paths to xmodmap; creating a new .desktop entry in ~/.config/autostart/; dropping the command into my .bashrc; editing crontab, using the @reboot; using the Garuda Boot Options (which does not open for some reason); and so on. Honestly, that's about half of the different strategies that I've tried, where each strategy has included lots of modifications based on what I've found recommended on forums. I feel like it should be easy to have a script run on startup, or at least to run the xmodmap command indicated above on startup since, at least currently, this is all that I need. Any help would be much appreciated. Here is my inxi -Faz:

System:
  Kernel: 5.16.1-zen1-1-zen x86_64 bits: 64 compiler: gcc v: 11.1.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=b81a6f3e-b667-450e-9f4d-9ad16bae681d rw [email protected]
    quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
    systemd.unified_cgroup_hierarchy=1 loglevel=3
  Desktop: GNOME 41.3 tk: GTK 3.24.31 wm: gnome-shell dm: GDM 41.3
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Laptop System: System76 product: Lemur Pro v: lemp9
    serial: <superuser required> Chassis: type: 9 serial: <superuser required>
  Mobo: System76 model: Lemur Pro v: lemp9 serial: <superuser required>
    UEFI: coreboot v: 2020-05-15_e2baafa date: 05/15/2020
Battery:
  ID-1: BAT0 charge: 51.0 Wh (93.4%) condition: 54.6/73.9 Wh (73.9%)
    volts: 8.8 min: 7.7 model: Notebook BAT type: Li-ion serial: <filter>
    status: Charging
CPU:
  Info: model: Intel Core i7-10510U bits: 64 type: MT MCP
    arch: Comet/Whiskey Lake note: check family: 6 model-id: 0x8E (142)
    stepping: 0xC (12) microcode: 0xEA
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
    L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
    L3: 8 MiB desc: 1x8 MiB
  Speed (MHz): avg: 1176 high: 2056 min/max: 400/4900 scaling:
    driver: intel_pstate governor: powersave cores: 1: 900 2: 1306 3: 2056
    4: 1389 5: 1057 6: 900 7: 900 8: 900 bogomips: 36799
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2
    mitigation: Enhanced IBRS, IBPB: conditional, RSB filling
  Type: srbds mitigation: TSX disabled
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel CometLake-U GT2 [UHD Graphics] driver: i915 v: kernel
    bus-ID: 00:02.0 chip-ID: 8086:9b41 class-ID: 0300
  Device-2: Chicony Chicony USB2.0 Camera type: USB driver: uvcvideo
    bus-ID: 1-7:2 chip-ID: 04f2:b685 class-ID: 0e02
  Display: x11 server: X.Org 1.21.1.3 compositor: gnome-shell driver:
    loaded: intel unloaded: modesetting alternate: fbdev,vesa display-ID: :1
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2")
    s-diag: 582mm (22.9")
  Monitor-1: eDP1 res: 1920x1080 hz: 60 dpi: 157
    size: 310x170mm (12.2x6.7") diag: 354mm (13.9")
  Message: Unable to show advanced data. Required tool glxinfo missing.
Audio:
  Device-1: Intel Comet Lake PCH-LP cAVS driver: snd_hda_intel v: kernel
    alternate: snd_soc_skl,snd_sof_pci_intel_cnl bus-ID: 00:1f.3
    chip-ID: 8086:02c8 class-ID: 0403
  Sound Server-1: ALSA v: k5.16.1-zen1-1-zen running: yes
  Sound Server-2: JACK v: 1.9.20 running: no
  Sound Server-3: PulseAudio v: 15.0 running: no
  Sound Server-4: PipeWire v: 0.3.43 running: yes
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel bus-ID: 02:00.0
    chip-ID: 8086:2723 class-ID: 0280
  IF: wlp2s0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8
    bus-ID: 1-10:3 chip-ID: 8087:0029 class-ID: e001
  Report: bt-adapter ID: hci0 rfk-id: 0 state: down
    bt-service: enabled,running rfk-block: hardware: no software: yes
    address: <filter>
Drives:
  Local Storage: total: 465.76 GiB used: 125.68 GiB (27.0%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung
    model: SSD 970 EVO Plus 500GB size: 465.76 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
    rev: 2B2QEXM7 temp: 55.9 C scheme: GPT
Partition:
  ID-1: / raw-size: 465.51 GiB size: 465.51 GiB (100.00%)
    used: 125.68 GiB (27.0%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-2: /boot/efi raw-size: 256 MiB size: 252 MiB (98.46%)
    used: 546 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 465.51 GiB size: 465.51 GiB (100.00%)
    used: 125.68 GiB (27.0%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-4: /var/log raw-size: 465.51 GiB size: 465.51 GiB (100.00%)
    used: 125.68 GiB (27.0%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-5: /var/tmp raw-size: 465.51 GiB size: 465.51 GiB (100.00%)
    used: 125.68 GiB (27.0%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 15.5 GiB used: 0 KiB (0.0%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 55.0 C pch: 53.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 348 Uptime: 4m wakeups: 1 Memory: 15.5 GiB
  used: 4.03 GiB (26.0%) Init: systemd v: 250 tool: systemctl Compilers:
  gcc: 11.1.0 clang: 13.0.0 Packages: pacman: 1578 lib: 377 Shell: fish
  v: 3.3.1 running-in: tmux: inxi: 3.3.12

Have you tried with xinit, as suggested in the Arch Wiki?
Alternatively, with a sleep time in autostart like here?

1 Like

I have tried editing the .xinitrc file in the home folder, coppied from /etc/X11/xinit/xinitrc, and adding sleep 10; xmodmap $HOME/.Xmodmap, as well as other things. I've also tried adding sleep to .desktop files in ~/.config/autostart.

I should say that adding xmodmap ~/.Xmodmap to .profile does work, but then when I open the terminal (I'm using Alacrrity), I get a message that it has run the command every time, and have been told in various places that .profile is not really the right way to do what I'm trying to do.

Check if this can help (an & to run it in background)

1 Like

Gnome/GDM has its own ways of doing things on login.
What you are asking advice for is targeted to systems that either don't use a Display Manager for login, or their DM parses dot-files using /etc/profile and /etc/X11/xinit/xinitrc

Bash describes what it does when logging into the session in the man bash manual. But are you using BASH??? I suppose you aren't. Find out what is your login shell and then look for info about how it parses login files and which ones.
A more experienced guy may know this easily and could add more info here :smile:

But first, I would suggest explaining the reason you want to use a custom xmodmap, while being in Gnome. Sometimes we think we have found the proper solution to our problem, while it may be wrong... :man_shrugging:

Various places is not the best first place to trust, when you can ask your distro support. :smiley:

2 Likes

I was worried about something like that, though I thought that the .desktop files were run by GDM. But I can't say I have a great understanding of all the pieces. With that said, your advice turns out to be quite apt. I found a post complaining that Gnome 40 does not yet offer tweaks which allows one to remap keys. However, I have tweaks installed (guess it has now compatible?), and didn't realise that you can remap keys that way. Two check-boxes later I could abandon xmodmap altogether, along with all of my attempts to get it to run on booting up. I'm delighted, though a little humiliated that it was so easy in the end. Thanks all for the helpful comments. I definitely appreciate the help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.