Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using dual monitor configuration (laptop + external CRT). Each time I lock my screen I need to restore my CRT screen parameters (actually refresh rate only) on next unlock. Screen refresh rate of external monitor is reset to 60Hz and desktop picture moved (or better to say compressed) to left creating black zone right.

I'm running following command to restore correct parameters

xrandr --output VGA-0 --mode 1280x1024 -r 75

I need to run this script each time I'm unlocking my screen and it would be nice to make this happening automatically.

Startup applications won't help as they run once only during system boot.

Another solution is to save those VGA parameters somewhere but I'm not sure how. Probably in /etc/X11/xorg.conf (which actually don't have) but I need to generate full config first and then put that 75 rate in it.


I can't understand why was this marked as DUPLICATE of another question where in the description a man says "... upon boot? (not upon user login)" and my question is inverted - "upon login (not upon boot)".

Also I mentioned that putting a script to "Startup applications" does not do the trick.

share|improve this question
I've found that Startup Applications runs every time I log in. For example, even if I log in multiple times without rebooting, even logging in more than one time at once (different ttys), I always hear the Imperial March once I added it to Startup Applications. – Novine Nov 1 '13 at 14:49
Hi Novine, I just tested this by adding 'echo date >> /tmp/log' in my script which added to startup applications list and unfortunately no new date records appear in the file on screen unlock. Please explain how did you test this? – gumkins Nov 3 '13 at 1:57
Sounds more like you want the following one, right? – LiveWireBT Nov 3 '13 at 8:14

Save your command in a file named .xprofile in your home directory.

share|improve this answer
What is the utility of the .xprofile file? – Lucio Nov 1 '13 at 19:33
From memory, it stores X parameters like the user is trying to do. – Jean-Marie Nov 1 '13 at 20:08
This does not work for me. – gumkins Nov 2 '13 at 21:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.