how to execute a command at the startup  [Solved]

Help for Current Versions of MX
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
wax
Posts: 25
Joined: Mon Dec 27, 2021 4:46 pm

how to execute a command at the startup

#1 Post by wax »

i try to use /usr/bin/xmodmap $HOME/.Xmodmap command at the startup
i use xfce
it's a way to make f8 and f9 capable to increase and lower the speakers

User avatar
wax
Posts: 25
Joined: Mon Dec 27, 2021 4:46 pm

Re: how to execute a command at the startup

#2 Post by wax »

i tried just to add the command at /etc/rc.local, above the exit 0 line
but the file don;t seem to be executed

Charlie Brown

Re: how to execute a command at the startup

#3 Post by Charlie Brown »

The .Xmodmap will already take effect, do you have the required lines in it correctly? Like

Code: Select all

keycode 218 = blahblah
Or.. what's the command exactly? (Assuming it works from a terminal).

User avatar
wax
Posts: 25
Joined: Mon Dec 27, 2021 4:46 pm

Re: how to execute a command at the startup

#4 Post by wax »

$ cat .Xmodmap
keycode 74 = XF86AudioLowerVolume
keycode 75 = XF86AudioRaiseVolume

/usr/bin/xmodmap $HOME/.Xmodmap works fine from a terminal

Charlie Brown

Re: how to execute a command at the startup

#5 Post by Charlie Brown »

"Session and Startup" - "App Autostart" tab, add new, any name, any description, command:

Code: Select all

sh -c "/usr/bin/xmodmap -e 'keycode 74=XF86AudioLowerVolume'"

Code: Select all

sh -c "/usr/bin/xmodmap -e 'keycode 75=XF86AudioRaiseVolume'"
(Add 2 new items)

If still not working we'll add some delay.


Or just:

/usr/bin/xmodmap /home/yourusername/.Xmodmap

as the command (particularly "the full path" as above , not $HOME or ~/... )

User avatar
wax
Posts: 25
Joined: Mon Dec 27, 2021 4:46 pm

Re: how to execute a command at the startup

#6 Post by wax »

it is not working. let's add some delay. how?

Charlie Brown

Re: how to execute a command at the startup  [Solved]

#7 Post by Charlie Brown »

Code: Select all

sh -c 'sleep 5 ; /usr/bin/xmodmap /home/yourusername/.Xmodmap'
or:

Code: Select all

sh -c "sleep 5 ; /usr/bin/xmodmap -e 'keycode 74=XF86AudioLowerVolume'"

Code: Select all

sh -c "sleep 5 ; /usr/bin/xmodmap -e 'keycode 75=XF86AudioRaiseVolume'"

User avatar
wax
Posts: 25
Joined: Mon Dec 27, 2021 4:46 pm

Re: how to execute a command at the startup

#8 Post by wax »

it is working. (i had to restart the system also.)
Ty so much ;)

Charlie Brown

Re: how to execute a command at the startup

#9 Post by Charlie Brown »

You're welcome :)

Which one did you use? The path or the commands?

Btw. maybe you mark the thread solved :)

User avatar
fehlix
Developer
Posts: 12772
Joined: Wed Apr 11, 2018 5:09 pm

Re: how to execute a command at the startup

#10 Post by fehlix »

wax wrote: Sat May 11, 2024 1:04 pm $ cat .Xmodmap
keycode 74 = XF86AudioLowerVolume
keycode 75 = XF86AudioRaiseVolume

/usr/bin/xmodmap $HOME/.Xmodmap works fine from a terminal
xmodmap will be reset when setxkbmap is running.
So you may need to delay b/c in session/autostart and somewhere in X-startup a setxkbmap is triggered.
Alternatively rename the autostart entry to something like
zz_xmodmap
which genrates a desktop file within:
$HOME/.config/zz_xmodmap.desktop
So it will run last within the list of entries, which are executed in order.

Locked

Return to “MX Help”