PDA

View Full Version : anyone willing to write a little ass-saving script? (for ati users)


abf
01-29-2006, 12:28 PM
Because my programing skills aren't l33t enough to take on this job, yet I think that it should be simple enough anyone can do it, i come to the forums with it.

The Action:
It shall switch from one video driver, to another (in xorg). Not exactly on the fly because ctrl+alt+backspace still needs to be pressed.

Why:
FGLRX does not take Suspend2 or Hibernate for that matter. By being able to easily, and quickly switch from fglrx > ati and then back to fglrx will let us, ati users hibernate without first editing the xorg.conf by hand.

How it will work (user end):
The script should execute by double clicking an icon on the desktop, or a quick launch button on the kicker / gnome-panel. Then a xterm will come up with something like

Select video driver:
1) ati
2)fglrx
#:


the user inputs the option (1 or 2) and the script does its thing. Now its safe for user to hibernate, or when they come out of hibernate, to get their 3d back (after resetting x or relogging in). Maybe even a step better, if the user pics to go to fglrx, the script will automatically reset xorg and bring up kdm or gdm login screen. And if the user pics ati, it won't do that since when you hibernate and then get out of sleep xorg resets anyway... so there is no point in extra resets.

maybe even a little later down the road somebody can write a front end for it so that the user has 2 radio buttons (ati and radeon) and then the "OK" button and "Cancel".

How it will work (the guts of the code):
There will be 2 xorg.conf files. xorg.conf and xorg.conf_alt. They are exactly identical except for the device being fglrx in one, and ati in another. Doesn't really matter which. Since xorg reads only the "xorg.conf" named file, thus rendering xorg.conf_alt useless, what will happen is the script will just rename the files.

for example. by default we start with
xorg.conf = fglrx
xorg.conf_alt = ati

user has fglrx loaded and wants to go to hibernate, thus turn on ati.
script renames files:
xorg.conf = ati
xorg.conf_alt = fglrx

user hibernates
user reloads system

user runs script to load fglrx:
files get renamed:
xorg.conf = fglrx
xorg.conf_alt = ati

xorg resets. kdm or gdm loads.

user logs in.

session continues.



---------------------

really just a rough idea, if somebody was to write this i am sure it would probably be worked out a tad better.


i know this may look messy, but at least for now (until ati gets their act together) it will make standby a little bit more managable for ati users


(unless i am missing something and there is already a proggy (or a fix) out there to make ati standby possible).

:thumbup:

DimGR
01-29-2006, 12:56 PM
is suspend2 working out ok for you though ?

abf
01-29-2006, 03:28 PM
suspend2 works great, as long as the open source ati drivers are loaded. once fglrx comes into play, the computer freezes when it gets out of of suspend.

seablade
01-29-2006, 10:46 PM
Heh of course another way to do this is to write a script to suspend your machine that would switch the drivers for you before the suspend command is called.

Since it seems that is the only reason you want to do this it might be a better way to do it, at least in my book.

Seablade

Still working on his Bash scripting, sorry. Its right up there with action script and PHP to learn to add to his repitoire.

DimGR
01-30-2006, 04:53 AM
you could try something similar to this




!/bin/bash

down_wireless() {
/sbin/ifdown eth1
pkill dhclient
/sbin/modprobe -r ipw2200
}

save_state() {
logger -t acpid "Saving state"
down_wireless
#/sbin/modprobe -r button
/bin/sync
vbetool vbestate save > /tmp/vbestate
chvt 1
}

suspend_to_ram() {
echo 3 > /proc/acpi/sleep
}

restore_state() {
logger -t acpid "Restoring state"
vbetool vbestate restore < /tmp/vbestate
/sbin/hdparm -S2 /dev/hda
/sbin/hwclock --hctosys
#/sbin/modprobe button
chvt 7
}

save_state
suspend_to_ram
restore_state




but change it to look for fglrx.....

abf
01-30-2006, 03:37 PM
write a script to suspend your machine that would switch the drivers for you before the suspend command is called.
.

that works too. as long as you can set it to change it back to fglrx and restart x as soon as you get out of suspend, or better yet have it change it at the stage where the core has loaded, but the gui hasn't, so that way when x finally comes up its already changed to fglrx. granted this will probably require a re-login on the user's part. still beats the alternatives we have today :)

seablade
01-30-2006, 03:44 PM
Considering something has to be called to return from a suspend, I couldnt see a reason why it couldnt be done like that. The catch is just finding out what the process suspend follows when returning from a suspend and seeing where you can insert an extra command in there. Might take a patch to suspend itself, who knows...

Seablade

bsmith
01-31-2006, 08:33 PM
I'll see if I can throw something together bash wise. I won't be able to test it as I don't do the suspend thing.