You are not logged in.
Pages: 1
Hai everybody. I am a laptop user and at home i have a docking station. So i switch hardware often. Ive written a lillte deamon that detect wheter i am using a dockingstation or not. Depending the configuration it copies the configuration files. When stopping the daemon (actually it isn't really a daemon....) it writes back any changes you made in de configfile you are using.
#!/bin/bash
# source application-specific settings
# general config
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Loading Hardware Profile"
if [ -r /dev/hdc ]; then
#Load Docking Configuration
cp /etc/X11/xorg.crt /etc/X11/xorg.conf
else
#Load Non-Dock Configuration
cp /etc/X11/xorg.lcd /etc/X11/xorg.conf
fi
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
stop)
stat_busy "Saving Hardware Profile"
if [ -r /dev/hdc ]; then
#Writing back possible changed configuration
cp /etc/X11/xorg.conf /etc/X11/xorg.crt
else
#Writing back possible changed configuration
cp /etc/X11/xorg.conf /etc/X11/xorg.lcd
fi
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
This code is quite simple actually it could be much more advanced but i have no expience in linux programming.
My laptop has no cd-drive, but the dockingstation has. so this line of code
if [ -r /dev/hdc ]; then
checks if there is a cd drive.
Offline
Hmmm, very interesting - it's one of those brilliantly simple ideas.
One possible addition, just for fun:
if "xorg.lcd" or "xorg.crt" don't exist, you can run `hwd -X` to generate a config file.
Otherwise this is pretty cool - if I had a docking stating I'd use this 8)
Feel free to post it in the wiki too, just in case someone searches for "docking station" or something
Offline
Hmmm, very interesting - it's one of those brilliantly simple ideas.
One possible addition, just for fun:
if "xorg.lcd" or "xorg.crt" don't exist, you can run `hwd -X` to generate a config file.
something
thnx. Concerning the hwd -X thingy. I need some special configuration for my xorg.conf (en option for my videocard (Option "CrtOnly" "true") so hwd -X aint working. The wiki in a good idea, but i think it should be a bit more advanced. Maybe i should write something like the new network profile stuff.
Offline
The wiki in a good idea, but i think it should be a bit more advanced.
This is a simple script, its a prime candidate for the Scripts section of the wiki:
http://wiki.archlinux.org/index.php/Category:Scripts
Others may improve it. I have no use for this either, but like phrakture, I think its a stroke of brilliance. :-)
Dusty
Offline
thnx. Concerning the hwd -X thingy. I need some special configuration for my xorg.conf (en option for my videocard (Option "CrtOnly" "true") so hwd -X aint working. The wiki in a good idea, but i think it should be a bit more advanced. Maybe i should write something like the new network profile stuff.
Well, yeah hwd won't work for everyone, however it will work fine for some (my crt/lcd switch is pure hardware, so i need no special config to get it working) - and you can only have it run if the file doesn't exist. It was just a random idea.
Offline
atze wrote:thnx. Concerning the hwd -X thingy. I need some special configuration for my xorg.conf (en option for my videocard (Option "CrtOnly" "true") so hwd -X aint working. The wiki in a good idea, but i think it should be a bit more advanced. Maybe i should write something like the new network profile stuff.
Well, yeah hwd won't work for everyone, however it will work fine for some (my crt/lcd switch is pure hardware, so i need no special config to get it working) - and you can only have it run if the file doesn't exist. It was just a random idea.
well the hwd -X thing aint a bad idea, maybe it takes to much time. Actually this script should include more like (network/usb-drivers) mount point. It would maybe be even better if it would run before the bootsequence enters an runlevel so you can configure your rc.local to your current hardware profile.
Offline
Pages: 1