Page 1 of 1

Running xmodmap at start-up

Posted: Mon May 13, 2019 7:33 pm
by hwalinga
Whenever I run xmodmap manually it works fine. However I can't get it to work automatically at start-up.

I made a ~/.Xmodmap file and tried creating a ~/.xinitrc and a ~/.xprofile with the following contents

Code: Select all

#!/bin/bash
[[ -f /home/hielke/.Xmodmap  ]] && /usr/bin/xmodmap /home/hielke/.Xmodmap
Did not work.

Next I tried creating a .config/autostart/keys.desktop file with the contents

Code: Select all

[Desktop Entry]
Name=xmodmap
Comment=Apply Xmodmap
Exec=/home/hielke/.keys
Icon=system-run
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
Did also not work.

Any more suggestions for me to try? Or is this the systemd madness everybody is talking about, and if I want proper control over my system I better look for a systemd free alternative ... ?

Re: Running xmodmap at start-up

Posted: Tue May 14, 2019 1:45 am
by catweazel
hwalinga wrote: Mon May 13, 2019 7:33 pm Any more suggestions for me to try?
Add the command to the end of .profile for a user-specific scope. If you want global scope, you can add a systemd service: viewtopic.php?t=275464
hwalinga wrote: Or is this the systemd madness everybody is talking about, and if I want proper control over my system I better look for a systemd free alternative ... ?
The only madness is that presented by rabid systemd opponents who know they're gibbering but don't know why.

Re: Running xmodmap at start-up

Posted: Tue May 14, 2019 9:43 am
by hwalinga
Thanks for your help, but both the .profile and the systemd service did not work for me.

Code: Select all

[Unit]
After=display-manager.service

[Service]
ExecStart=/home/hielke/.keys.sh

[Install]
WantedBy=default.target
My memory might not be that good, but I thought this was a lot easier to do before my system was using systemd.

Re: Running xmodmap at start-up

Posted: Thu May 16, 2019 8:44 am
by hwalinga
Add the command to the end of .profile for a user-specific scope. If you want global scope, you can add a systemd service: viewtopic.php?t=275464
Unfortunately it did not work.

Re: Running xmodmap at start-up

Posted: Tue Apr 07, 2020 9:17 am
by Prouflon
Hello. After many many tries, I think I finally was able to reliably make xmodmap autostart properly.

The reason why this problem is so unfathomably hard to troubleshoot is that
ADDING "xmodmap $HOME/.Xmodmap" TO ANY OF SCRIPTS MENTIONED ABOVE DOES NOT WORK!
but executing it from the command line works fine.
I have no Idea why this is, but it might have to do with those files being executed too early for xmodmap to properly modify the X server.
Adding a delay naively doesn't help either.


Solution:
---------------------------------------
Add this line to the startup script of your choice (".xprofiles", ".config/xfce4/xinitrc" and the xfce4 application autostart gui worked for me):
bash -c "sleep 5; xmodmap $HOME/.Xmodmap" &
---------------------------------------

The '&' at the end is important because it tells the script to run this command in the background while the session continues starting. Waiting 5 seconds ("sleep 5") worked well for me, but if your computer takes a little more time logging in, it might be required you increase this value.

If you hate bash:
sh -c "sleep 5; xmodmap $HOME/.Xmodmap" &
should work too but I haven't tested this.

Re: Running xmodmap at start-up

Posted: Tue Jul 28, 2020 5:33 pm
by bobcatos
Correction on that filename: it should be ".xprofile", not ".xprofiles".
It works on LM 20 using MATE, OpenBox, and IceWM.

Re: Running xmodmap at start-up

Posted: Wed Feb 03, 2021 9:03 pm
by ysf
bobcatos wrote: Tue Jul 28, 2020 5:33 pm Correction on that filename: it should be ".xprofile", not ".xprofiles".
It works on LM 20 using MATE, OpenBox, and IceWM.
thanks for this it works :)

Re: Running xmodmap at start-up

Posted: Sat Jan 08, 2022 2:38 am
by cebroski
This worked for me too .... BUT please note that for Linux Mint version 20.2 Cinnamon 64-bit the filename that I used was .profile, NOT .xprofile and NOT .xprofiles.

Thank you! :)