Run a command at startup


Recommended Posts

I've been playing with getting a dual screen setup working using the Intel driver and xrandr. Previously I was doing this with the old i810 driver and some xorg tweaks, but xrandr seems a lot neater, and the i810 driver has been depricated in favour of the intel one.

Anyway, I can "trigger" a dual display from a terminal with

xrandr --output LVDS --mode 1024x768 --output VGA --mode 1024x768 --right-of LVDS

but of course ideally I'd like to run this line automatically whenever somebody logs in. I have read that it's possible to include some of this in xorg.conf, but I've tried without success. As X loaded it was spread across both screens, but then GDM appeared on my right screen only, and when I logged in I was back to a mirrored display. It seems to me, though, that if one simple command is all that's needed then surely I can leave xorg.conf alone and just "somehow" execute it.

"Somehow" is the question I'm asking :D

Link to comment
Share on other sites

Depending on how you start x, you could possibly put this in your ~/.xinitrc (if you use startx or xinit for example). If x is started automatically at boot, I'm not sure.

Link to comment
Share on other sites

Elv13 - thanks!

Gnome-sessions was the key to this. I put the command into a text file and saved it as /usr/bin/xrandr.sh, and made it executable. I then simply added xrandr.sh to the entries in "sessions". Such a simple solution in the end...

For those interested, here's the file

#!/bin/bash
xrandr --output LVDS --mode 1024x768 --output VGA --mode 1024x768 --right-of LVDS
gconftool --type int --set /apps/panel/toplevels/top_panel_screen0/monitor 1
gconftool --type int --set /apps/panel/toplevels/bottom_panel_screen0/monitor 1

The two gconftool entries are necessary because Gnome always calls the external monitor "screen0" which causes all the panels to be drawn on the secondary screen. These two entries force them to appear on my laptop screen.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.