LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 06-12-2006, 01:06 PM   #1
aoberoi
LQ Newbie
 
Registered: Mar 2006
Posts: 17

Rep: Reputation: 0
Setting keys on keyboard using xmodmap


I have a Logitech keyboard that has some multimedia keys that I'd like mapped so i can use them when im in Ubuntu. I figured out that the way i can make them work is if i run
Code:
xmodmap ~/.Xmodmap
to map my keys to the custom map i stored in my home folder and then go to System->Preferences->Keyboard Shortcuts and map the keys to the action i want in there.

My question is, how can i automatically run all of that without my input at the beginning of every time i log in? Is there a script i can write to make the Keyboard Shortcuts part to happen too? Where would i put this script and how exactly would i write it (I've never written shell script before i just happen to know what it is)?

Anyone that has any advice for me would be much appreciated. Thanks
 
Old 06-13-2006, 07:18 AM   #2
saltire
Member
 
Registered: Feb 2005
Location: Christchurch, NZ
Distribution: Kubuntu Dapper 6.06
Posts: 43

Rep: Reputation: 15
Hey Aoberoi,

I can tell you jow to do it in KDE - don't know if that will help, since if you are using Ubuntu (and not Kubuntu), you'll be using Gnome. Might be similar though.
I'm presuming that you already have an Xmodmap file with your preferred keysims saved in it...

1. Go to /home/your_user_name_here/.kde/Autostart
2. Create a text file called something like 'init_media_keys.sh'
3. Open this new shell script file in a text editor and enter the lines:
Code:
#!/bin/bash

xmodmap ~/.Xmodmap
and save it.
4. Log out of your account, log in again. The script should have executed upon login, and your keys should now be assignable.

Good Luck!

saltire
 
Old 06-13-2006, 07:23 AM   #3
saltire
Member
 
Registered: Feb 2005
Location: Christchurch, NZ
Distribution: Kubuntu Dapper 6.06
Posts: 43

Rep: Reputation: 15
Ah. You do have an Xmodmap file.
Oh yeah - Don't forget to make the script executable (in the permissions settings for the script).
 
Old 06-14-2006, 01:23 AM   #4
aoberoi
LQ Newbie
 
Registered: Mar 2006
Posts: 17

Original Poster
Rep: Reputation: 0
thanks for the help... im looking around for an equivalent of the autostart directory in gnome and i cant seem to find it... i'll keep looking.

also do you know how i could take care of the second part, where i am going into System->Preferences->Keyboard Shortcuts each time i log in to assign the keys, automatically in a script?
 
Old 06-14-2006, 02:24 AM   #5
saltire
Member
 
Registered: Feb 2005
Location: Christchurch, NZ
Distribution: Kubuntu Dapper 6.06
Posts: 43

Rep: Reputation: 15
Managed to get onto a Gnome desktop

Okay, here goes:

Create your script like I mentioned above, save it in your home folder as 'init_media_keys.sh' or something, and make it executable.

Next, go to the System menu on the top task bar, select 'Preferences', then 'Sessions'.
A window should appear with three tabs in it, the last of which should be 'Startup Programs'.
Go to this tab, click add, and point it to your shell script.

Log out, log in again, and you should now be able to assign those keys in 'System' -> 'Preferences' -> 'Keyboard Shortcuts'.
The keys you assign should be persistent, i.e. you shouldn't need to assign them every time you log in.

I didn't have time to test whether or not this actually works, but it should... If not then at least the answer will be in that general direction.

Good Luck,

saltire
 
Old 06-14-2006, 09:59 PM   #6
fragos
Senior Member
 
Registered: May 2004
Location: Fresno CA USA
Distribution: Ubuntu 10.10
Posts: 1,466

Rep: Reputation: 51
I'm not running xmodmap but the keyboard shortcuts I've set in System-> Preferences-> Keyboard Shortcuts survive reboots without any additional changes.
 
Old 06-16-2006, 12:29 AM   #7
aoberoi
LQ Newbie
 
Registered: Mar 2006
Posts: 17

Original Poster
Rep: Reputation: 0
apparently ive solved the keyboard problem without needing to make a script on startup. It turns out it was a lot simpler to just modify the /etc/X11/xkb/symbols/inet file which stores teh default keycodes for cpecific internet keyboards. for me i jumped down to logitech and changed an even which was defined to 2 keys simultaneously. I restarted X and it started working.

Thanks for the help guys and im sure writing shell scripts for automatic exceution on startup will be something ill use in the near future.
 
Old 06-18-2006, 01:50 AM   #8
saltire
Member
 
Registered: Feb 2005
Location: Christchurch, NZ
Distribution: Kubuntu Dapper 6.06
Posts: 43

Rep: Reputation: 15
Well there you go.

My keyboard is just a no-name generic thing that happens to have some media and internet function keys that weren't mapped, so I needed the scripts.

Glad to be of service.

saltire
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xmodmap and spezial keys like 'Mail' Gerard_2009 Linux - Software 1 04-04-2006 01:06 PM
Keyboard and it's shortcut keys ZakuSage Linux - Hardware 4 06-13-2005 02:11 PM
Assigning keyboard shortcuts to keyboard keys the who Linux - Hardware 3 02-20-2004 09:36 PM
Need help setting up "extra" keys on a Logitech iTouch Keyboard. Theoutdoorsman Linux - Software 4 11-16-2003 10:02 AM
Need help setting up the "extra" keys on my Logitech iTouch Keyboard Theoutdoorsman Linux - Hardware 1 10-16-2003 05:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 11:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration