Author Topic: Is it possible to have an executable file which is run after Suspend/Hibernate?  (Read 1283 times)

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing

I just became a proud owner of a Samsung NC10. I've installed PCLOS on it, updated to KDE4 but with compositing switched off. I'm working on the acpi stuff, but whatever system I use to suspend or hibernate, I get the same problem: On return, though the computer's wireless ethernet can see wireless signals, it can't connect to them.

However, I opened a terminal as root, and created a file consisting of these four lines:

Code: [Select]
#/bin/bash
rmmod ath_pci
sleep 1
modprobe ath_pci

which I saved at /usr/local/bin/restart-wireless and made executable.

and then added this line to /etc/sudoers

Code: [Select]
davecs localhost = NOPASSWD: /usr/local/bin/restart-wireless

Finally created an icon which formed a shortcut to "sudo /usr/local/bin/wireless"

This is a bit of a kludge, and it's not good to fool around with /etc/sudoers at the best of times. The ideal solution would be a way to get the removal and restoration of the ath_pci module included. Of course this will vary from one wireless connection to another, but if there was a user-definable file which could be added in if necessary, that would be great.

Anyone have any ideas?
PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing

I have found since that the uvcvideo module needs to be reloaded also after a suspension.

It occurred to me that, there is an executable bash file at /etc/rc.d/rc.local which users can edit if all else fails to ensure that certain commands are run at the end of the startup sequence. Is there a similar file for restoring from suspend or hibernate?
PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 4037
Interesting question. The problem is that so far as the system is concerned, the only thing that's happened is that the clock has jumped forward a few hours or days. It hasn't been rebooted - just put back exactly as it was and set running again.

You could have a script running in a loop which checks the connection is still alive every minute or two and does the necessary if not. If the loop is running when you suspend it should still be running when you come back, do it should soon detect the problem and correct it.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing
That's an idea. I wrote a loop script a few years ago for a Speedtouch 330 (which you have) and previously for a CDCether modem, because they got dropped from time to time.

Since my earlier post, I discovered that reloading the uvcvideo module doesn't work! After a suspend, the webcam is dead. Wonder if in both cases, it's a firmware issue.
PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6269

you can solve your problem by investigating what script rans when the system comes up and inject your script in that script

.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing
You'd think so, but when I add the necessary lines to /etc/acpi/pm-fallback-suspend it doesn't stay suspended, it comes back straight away! Weird or what?
PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook

flux

  • Guest
I use this script to suspend or hibernate my laptop (comment out the commented lines if you will have problems with the video after resume):

Code: [Select]
#!/bin/sh

# discover video card's ID
#ID=`/sbin/lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`

# securely create a temporary file
#TMP_FILE=`mktemp /tmp/video_state.XXXXXX`
#trap 'rm -f $TMP_FILE' 0 1 15

# switch to virtual terminal 1 to avoid graphics
# corruption in X
chvt 1
/sbin/hwclock --systohc

# write all unwritten data (just in case)
sync

# dump current data from the video card to the
# temporary file
#cat /proc/bus/pci/$ID > $TMP_FILE

# suspend
echo -n mem > /sys/power/state

# hibernate
echo -n disk > /sys/power/state

/sbin/hwclock --hctosys

# restore video card data from the temporary file
# on resume
#cat $TMP_FILE > /proc/bus/pci/$ID

# here I add my commands to restart network or something else
# but wireless is back by default and connected
# /etc/init.d/network restart

chvt 2

# remove temporary file
#rm -f $TMP_FILE


flux.

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing
The problems on the NC10 run rather deeper. A lot of stuff to put this right seems to be in the 2.6.28 kernel, where about half the "extended" keys fail to register being released in earlier kernels. So it's impossible to assign some of the Fn+F keys because if you assign an action it will keep repeating until you hit another key! The Volume Up/Down/Mute, Touchpad On/Off and Sleep do work, though.

As well as the wireless problem, which is curable with the rmmod/modprobe, I've found 3 more after suspend/hibernate. Webcam won't work even if you rmmod/modprobe uvcvideo, USB storage doesn't work, and further suspends become hit and miss!

What I think needs to be done is to reload a number of firmwares (at a guess).

This is all a shame, because the basic operation of the machine is about perfect, webcam identified with no problem. Sound just works. Someone somewhere on the board said that the mic didn't work, but that was because KMix was defaulting to the mic socket (mic), but the setting can be changed in KMix to "Front Mic". Or the other way round I'm on the desktop at the moment. But no difficulty getting the Skype Call Test to work.

Much of the ACPI does work, getting CPU scaling when running on battery. So overall it's good, just a few things that I hope will be resolved in a later kernel.

And of course the keyboard is a beaut for this type of machine.
PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook

Offline Ɗα√ϵς§

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5521
  • PCLinuxOS: A revolution in personal computing
I have found the solution to the wireless on/off after resume. It's simple - you have to use the ath5k module instead of the ath_pci. Well it sounds simple but it isn't.

First you need to upgrade to the 2.6.27.31 kernel. This fixes the problems with the Webcam and USB Plugins after suspend and resume. You have to remove dkms-madwifi and madwifi from synaptic, add the line "ath5k" to /etc/modprobe.preload, remove the files /etc/udev/rules.d/70-persistent-net.rules and /etc/sysconfig/network-scripts/ifcfg-ath0 and then go into the control centre to remove ath0 from the network interfaces.

Then you need to reboot and go into the control centre (not net-applet) to start up your new wifi interface based on ath5k module.

I might do a how-to for the NC10, spelling all this out for those less experienced in digging around!

It was well worth the effort.

PCLinuxOS has no wealthy sponsors and can only survive with your donations! Don't wait it might be too late.

Running PCLOS on Athlon II/250 with 2Gb Ram using ASUS M2N68-AM Plus Mobo with Nvidia GF7600GT graphics, and Samsung NC10 Netbook