Sleep script
I'm trying to make a 'deepsleep' script that puts my computer to hibernate, but puts the sleep settings back to sleep only after hibernating (so I can just close my laptop for sleep only, without having to change the configuration).
I constructed a script to achieve this, and for just a moment I considered myself a genius:
*do shell script "sudo pmset -a hibernatemode 1"*
*tell application "System Events" to sleep*
*do shell script "sudo pmset -a hibernatemode 0"*
I have to add that I fiddled with my configuration so that I don't have to give my root password for executing these commands.
My moment of genius was only short. This works perfectly when running it from the scripteditor, but does not work as soon as I save the script and try to run it from Spotlight (and that was my ultimate goal). Not working means that my script is executed, but it goes into sleep only, not hibernation as expected. It seems like the last line of the script is executed before the system goes to sleep. It also takes a very long time between the screen going blank and the actual sleeping (also for sleep only), which is not the case in the script editor.
Two questions:
1. Why is there a difference between running a script from the script editor and SpotLight, and what are these differences?
2. Any suggestions on how to make it work?
If you need more on configuration to answer this question, I will be happy to provide it.
greets,
Nelis
Solution on:
http://bbs.macscripter.net/viewtopic.php?id=27090
Similar Messages
-
[SOLVED] Why doesn't this systemd sleep script work as expected?
Hey all,
After having a service file to restart an application (that outputs text to the root window for DWM's statusbar) that kept failing numerous times, I decided to go back to the good old scripts to manage things. I already have one in use for my powersaving scripts, that looks like this:
#!/bin/sh
case $1/$2 in
pre/*)
/usr/bin/powersave false ;;
post/*)
if cat /sys/class/power_supply/BAT1/status | grep Discharging > /d$
then
/usr/bin/powersave true
else
/usr/bin/powersave false
fi
esac
I based the new script on it, which looks like this:
#!/bin/sh
case $1/$2 in
pre/*)
/usr/bin/killall dwmst
post/*)
/usr/bin/sleep 3 && /usr/bin/dwmst &
esac
But it's not working after suspend; my application is not launched. When I run the script from the terminal, it does work as expected. Here's the output of journalctl:
nov 22 15:05:48 edge systemd-sleep[7405]: /usr/lib/systemd/system-sleep/dwmst.sh exited with exit status 1.
What is wrong here?
EDIT 23-12-2013: I went back to a systemd service file.
Last edited by Unia (2013-12-23 00:04:40)If you test it by putting some things in there that print to a file or the journal or something, do they show up? I'm just wondering if the formatting is somehow screwed up (which it doesn't appear to be), or if it might be some kind of a race between the things run by /usr/bin/powersave and the things it writes to.
-
Sleep problems after 10.7.5 Update
Hi - After updating to 10.7.5 I have found my sleepwatcher sleep script which runs osascript times out with a PM Timeout.
Does anyone else have this problem?
Have Apple changed what happens on Sleep - for example disabling osascript or killing other processes or changing the order of what happens?
Thanks
TerryIt appears that this is not an uncommon problem:
https://discussions.apple.com/thread/3864270?start=45&tstart=0
(In my case it was a file permission problem.) -
Login on waking from sleep, but not screensaver / sleep display
Hi all, been trying to get rid of the login from screen saver / sleep display, while keeping the login on waking the computer from sleep. The reason I want to do this is because I frequently use a Hot Corner to sleep the display while listening to music etc, and having to enter a password just to change tracks etc is a pain But obviously I want to keep the password protection when the computer is put to sleep, as it always is when left unattended.
Anyway, based on initial Googling, I first tackled the problem by installing SleepWatcher from http://www.bernhard-baehr.de/, and adding this line to the global /etc/rc.wake script:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
However, this wasn't very satisfactory, because after waking the computer up from sleep, you initially get a normal session, which then suspends after 3 or 4 seconds. During this time you can interact with the session as normal and move windows etc, so it kind of gives you the impression that you don't have to log in, and then you do, so it's a bit clunky, and also doesn't feel very secure.
I thought I managed to improve the situation by moving the 'suspend' command to SleepWatcher's /etc/rc.sleep script instead of the /etc/rc.wake script - meaning that your session is suspended just before sleep, so it's already suspended when you wake the computer up. But then I noticed an even worse problem - my "Sleep Display" Hot Corner stopped working after SleepWatcher suspended my session!
Yes that's right, every time the 'suspend' command ran in conjunction with SleepWatcher, my "Sleep Display" Hot Corner got disabled, and didn't get re-enabled until I completely logged out and back in (or rebooted). So I stopped using SleepWatcher, by removing the 'suspend' command from any SleepWatcher scripts, and now Hot Corners work as normal again following successive sleeps.
So next I thought, maybe I could write an AppleScript that toggles the "Require password..." checkbox in System Preferences, perhaps to use in conjunction with SleepWatcher, so that the checkbox is disabled when the display is put to sleep, and enabled when the computer is put to sleep. I actually got as far as writing an AppleScript that toggled the checkbox, and was about to attempt to integrate it with SleepWatcher...
...then I stumbled across an old thread, where they talk about updating plists under com.apple.screensaver, in order to solve a slightly different problem:
http://forums.macosxhints.com/showthread.php?t=14085
Despite the thread being a few years old and trying to solve a different problem, the following command sounded hopeful so I thought I'd try it:
defaults -currentHost write com.apple.screensaver askForPassword -int 0
...and lo and behold, it works!
My mac is now behaving exactly as I want it - prompting for password on wake from sleep in the normal way as it did before, and not prompting when I merely wake the display (or screensaver)!
This is in conjunction with having the "Require password to wake this computer from sleep or screen saver" checkbox turned ON in System Preferences.
But the puzzling thing is, why does it work? Is it safe? Are there any side-effects and am I likely to need to re-enable it following software updates? Does it work for anyone else?
When I query the values under com.apple.screensaver, I get the following... I have no way of telling what the askForPassword value was before I changed it:
$ defaults -currentHost read com.apple.screensaver
askForPassword = 0;
idleTime = 0;
moduleName = Flurry;
modulePath = "/System/Library/Screen Savers/Flurry.saver";
tokenRemovalAction = 0;
Basically I'm very surprised that a simple one-line command seems to solve the problem, when there are so many threads where people have asked the same question, and either been told it's not possible, or told you need to do weird stuff with SleepWatcher and/or Applescript, which is often incompletely explained, more complex and less effective.
So, is the one-line askForPassword solution too good to be true?Thanks. I think for an office-type environment, it is an unusual requirement.
But let's not forget, more and more people use their computers in living-room type environments, for tasks such as playing music or watching films on a remote display. You're typically in a much darker ambience, which you don't want that to be shattered by the bright, white glare of a computer screen all the time!
So you need total control over whether the display is on or off. This has nothing to do with leaving the computer unattended. You're still there, "using" the computer, you're just not necessarily using the display.
Anyway... you are right, I toggled the "Require password..." setting in System Preferences off and then on again, and the "askForPassword" plist value changed itself to 1.
However... the behaviour of my mac has not changed. It behaves the way I want it (prompt for password on waking the compuer, but not on waking only the display), regardless whether the value of askForPassword is 0 or 1.
Even after rebooting.
Strange... what have I done? -
Location custom startup/resume script
I tried to figure it out using the search function but i couldnt get the answer i was looking for. After following the wiki and installing everything i needed to control my fan speed and so on, my fan keeps spinning very fast. I read many threads and the only thing that seemed to be working was forcing my fans with the code below. Now i used the search alot but i couldnt figure out how to add the code so it will run at boot and after resume from suspending. Is there anyone who can tell me how i can fix this?
# echo 0 > /sys/class/thermal/cooling_device3/cur_state
# echo 0 > /sys/class/thermal/cooling_device4/cur_state
# echo 0 > /sys/class/thermal/cooling_device5/cur_state
# echo 0 > /sys/class/thermal/cooling_device6/cur_state
/Edit: Typo.
Last edited by Greenify (2015-01-31 20:23:12)snakeroot wrote:
Greenify wrote:Eventually i want this to run on boot also, but im still searching how i must get it to work.
The detail you need is in man 5 tmpfiles.d
Try creating a file named fan.conf in /etc/tmpfiles.d
Then edit it to add the following line:
w /sys/class/thermal/cooling_device*/cur_state - - - - "0"
This assumes you are trying to write to every single cooling_devicex file. If not, you'll need to modify the blob in the path.
Obviously, I'm not passing on the wisdom of shutting off any or all of your fans. It's your system: you break it you keep all the pieces.
I followed your advice and read the man pages of the tmpfiles.d and it seems that is exactly what im looking for. I have just tested it out and it works like a charm, thank you. As for forcing the fans to a state, the reason i do this is because no other method seems to work. CPU temperature wont pass 43 degrees when i use this laptop for normal tasks. When they are forced that is.
nstgc wrote:I have to do something like this for bcache at boot. I use tmpfiles.d and it works great.
I agree, it works like a charm!
/Edit:
Greenify wrote:
whoops wrote:Not sure if it's the right place though - I think you might not be supposed to change (/add) anything directly in /usr/lib/systemd and instead maybe copy it to /etc/systemd (?)... but I'm not sure if that applies to scripts like that, or might be confusing it with stuff in /usr/share -.-
You got a good point there, ill look it up this week and post my findings here.
This is what it says in the wiki:
Hooks in /usr/lib/systemd/system-sleep
An example of a custom sleep script:
/usr/lib/systemd/system-sleep/example.sh
#!/bin/sh
case $1/$2 in
pre/*)
echo "Going to $2..."
post/*)
echo "Waking up from $2..."
esac
Last edited by Greenify (2015-02-02 22:29:04) -
[DONE] Bash scripting. A few questions
Hi,
I've created my own custom sleep script as it is described here: https://wiki.archlinux.org/index.php/Sy … stem-sleep and it's already working correctly.
However I've got a few questions concerning bash scripting since I've never did it before.
Here the example from the wiki:
#!/bin/sh
case $1/$2 in
pre/*)
echo "Going to $2..."
post/*)
echo "Waking up from $2..."
esac
Now what do I need the /*) for in the cases pre and post? What does it do? And why isn't there any *) in the end which would exit the script if none of the above is true?
Secondly, why does it say case $1/$2 in, but not case $1 in, what is the $2 needed for? E.g. in this script only $1 is used: https://wiki.archlinux.org/index.php/OS … ibernation
And third question is, if I do really need the double quotes around $1? Does it make any difference?
Sorry for my incompetence but I'm not a dev and as I already said I've never did any bash scripting...
Thanks in advance
best regards
nuc
Last edited by nuc (2013-02-07 18:10:56)ok, here's my actual code:
#!/bin/sh
suspend_osssound()
/usr/lib/oss/scripts/killprocs.sh
/usr/sbin/soundoff
resume_osssound()
/usr/sbin/soundon
case "$1" in
pre)
suspend_osssound
post)
resume_osssound
*) exit $NA
esac
It is the same as the one in the OSS wiki entry, but slightly configured to work under logind and not pm-utils. Of course the new location is /usr/lib/systemd/system-sleep/.
I'm about to update the wiki with my code, so I'd like to know if there aren't any major mistakes. I tested it and it works but I want to get sure
PS: Do people actually still use pm-utils for suspending or can I safely remove the previous script from the wiki?
EDIT: Added double quotes
Last edited by nuc (2013-01-25 23:42:02) -
Is there any way to control the volume of iTunes on Windows with a script? I suspect Teridon would be able to answer this...
What I'd like to do is have a "sleep" script that will slowly fade the volume out (over a period of several minutes, say 15 minutes) and then stop playback. I'd be happy to write it, but I can't find any resources for how to write applescript in a Windows environment. Can anybody help?
Thanks,
loosenutloosenuƬ wrote:
You are awesome. I was working on this in parallel and came up with this:
http://pastebin.com/SxCqkv2T
I borrowed your PreFade idea, thanks for that, hope you don't mind.
Of course not. Feel free to rummage around the rest of my scripts for anything useful.
I included some functionality to fade the windows volume after fading the iTunes volume (requires NIRCMD.exe, get it here: http://www.nirsoft.net/utils/nircmd.html). I did that because the jump from volume level 1 to 0 is actually pretty abrubt.
Ah yes, I had the master volume down low (I'm at work) which is why I thought there might be a use for a minimum fade to level. I tried to think of other gotchas like not assuming you are starting at full volume, or even playing. In truth the thing would be about 10 lines of code with no comments or error checking rather than the 90 or so I knocked out.
I'm sure you can cook up a little local web site to trigger your script.
tt2 -
The goal: secure, convenient, automated login to password-protected sites
KeyPass is a great open-source program for secure creation, storage and use of login passwords and other information. With a plugin called KeeForm, it allows very convenient automatic login to password-protected sites by clicking on a KeePass entry. To preclude unintended access to all of your secure information, it is wise to close Keepass after each use, or set Keepass to lock when minimized. But this is less convenient, because a long secure master password then has to be entered before each use of Keepass.
Using a fingerprint reader to enter Keepass can be a big time saver while retaining security. Capacitive swipe fingerprint readers can be very secure, provided they operate through equally secure software. They are available as USB units, or integrated into some keyboards and notebook computers, for example some Lenovo ThinkPads.
Unfortunately, set-up can be a challenge and there may be disadvantages even after the best workable interface between KeePass and a particular biometric system. This example uses the integrated fingerprint reader and software on a Lenovo ThinkPad X61.
The problem: getting secure fingerprint software to use KeePass
ThinkPads can use Lenovo fingerprint software alone for start-up into Windows, but they need additional layers of software (Client Security Solution - CSS, and Password Manager - PM) to work with other programs including KeePass. PM uses CSS security functions.
Cautions about Lenovo CSS:
1. Some organisations advise against CSS because of problems including clashes with antivirus programs. See http://www.ncsu.edu/antivirus/lenovo/ and
http://prowiki.isc.upenn.edu/wiki/ThinkVantage_Software_Under_Windows_Vista
These bugs may have been fixed over time - but install at your own risk!
2. CSS and PM introduce their own system overheads which may slow some operations.
3. Once tried, CSS may not simply be inactivated while restoring basic fingerprint start-up into Windows. The X61 at least insists that CSS be reactivated for any fingerprint function. If you try a Windows system restore to a time before CSS was first activated, you may experience the ‘blue screen of death'. The security chip evidently regards your desire for a past configuration as a security breach. With luck you may ‘live again' if you can log into Windows in Safe Mode to undo the attempted system restore. After that, I reactivated CSS. I was not game to try uninstall after inactivation of CSS - but see the ncsu link above.
Having decided to accept the ‘risks' of activating CSS and PM, you may want to try PM for all password management. For me it would not recognise some internet logins, could not complete auto-submission in others, and did not allow the manual adjustments that make KeePass so versatile. Unfortunately PM help is very limited. There is no current user manual (old manuals up to v1.4 available on the web do not match the properties of the current v3 of the software). KeePass (or the KeeForm plugin) also struggles with some sites, but it works much better overall. Help on KeeForm plugin syntax is limited, but otherwise KeePass help is great.
So we really want the fingerprint reader (via PM) to work for KeePass master password entry.
This is not so simple for five interacting reasons:
(i) It is tricky to register KeePass in PM;
(ii) PM then gets confused by ‘hidden' entry of a master password during fingerprint login to KeePass, and repeatedly tries to save ****** as a changed master password;
(iii) PM also tries to automatically register each entry opened for editing within KeePass;
(iv) PM tries to automatically register other logins even if they are managed through KeePass.
(v) Your KeePass records are now only as secure as your PM login (which is likely to be your Windows login).
The solutions: or workarounds at least
The best workarounds I could develop for these five issues were:
(i) To register KeePass in PM, first ensure that PM is running (icon in the system tray). Then launch KeePass, click the login window box for unobscured password display (three blue dots turn black), enter the master password and click OK to start KeePass as usual.
If PM does not offer to save an entry for KeePass by this stage, try ‘plan B'. Open a window to edit an entry in KeePass, then click Cancel. PM seems to recognise this more readily as a login window and may offer to create an entry. Accept the offer, and name the entry KeePass. Then open PM to edit the saved entry. You will have to edit several fields to achieve an effective PM entry for KeePass:
The title field must be "Open database - database.kdb", to match the title of the KeePass login window.
The file name field should show the full path to KeePass.exe (something like C:\Program Files\KeePass\PeePass.exe depending on your installation).
The login and password data field is accessed by double clicking the entry. It will need to show only your KeePass master password (in the unobscured text view). In login and password data, delete each line of unwanted text until you get to the final password line (shown as *****), and edit this line to provide your master password.
In the Advanced tab, select auto-fill and auto-submit and the desired security level [see (v) below]. Then select OK to get to the PM front window, and File - Save Changes, then Exit.
Now when you close and re-launch KeePass, PM should automatically intervene (requesting a fingerprint to complete the KeePass login if you selected that security level. Select ‘No' when PM asks to change the password [see (ii) below].
If you had no luck, try ‘plan C'. Close KeePass completely, then launch it again to open the login window. Then right-click the PM icon in the system tray, open the ‘Type and Transfer Tool', click the box for unobscured password display, type in the KeePass master password, drag the cross-hairs to the password field in the waiting KeePass login window, and release the password there. Click OK to start KeePass as usual, then click OK to close the PM transfer window. If there is still no KeePass entry in PM, check that KeePass has not been included in the PM excluded programs list. If this sequence does not work, reboot and check again. Failing all else, any entry that PM succeeds in making from any login page can be edited to an effective KeePass entry by editing fields as described above for ‘plan B'.
PM (v3.00) can be coy to associate initially, but it will accept KeePass (v1.14) as a password-managed program, and thereafter it reliably succeeds to auto-submit the KeePass login after some help described in (ii) below.
(ii) Having sent the correct master password to the KeePass login window, PM becomes confused by the ‘hidden' text now in the password field, and offers to change its record of your KeyPass master password to ******. You can manually select ‘No' in the PM changed-password dialogue box that appears every time you use PM / fingerprint for KeePass login. But Beware: if you ever accidentally select ‘Yes' (the default) your KeePass master password record in PM will be changed to ******. This can be edited to provide the correct password again, but it is more than a minor pain in the AR5E. Unless you know (or have a backup of) your KeePass master password you just lost access to your KeePass database!
To avoid this big nuisance and risk, you can set up to restart KeePass for each use from a desktop shortcut (instead of minimising it to the system tray) and have the shortcut run a batch file with vbs scripts that send the ‘No' message to PM automatically.
Here is an example batch file, with corresponding vbs scripts. You can make all these files using Notepad and save the files with the names indicated, into the KeePass program directory (C:\Program Files\KeePass in this example).
KeePass.bat (This launches KeePass and tells PM v3 not to change the password. Caution: If Lenovo changed PM program design in future, the effect could change; the batch file might send {TAB}{ENTER} keystrokes to another open window on your computer):
C:
cd\
cd "C:\Program Files\KeePass"
start " " "C:\Program Files\KeePass\KeePass.exe" "C:\Program Files\KeePass\Database.kdb"
start /w Sleep.vbs 1
start /w AppActivate.vbs
start /w SendKeys.vbs
Sleep.vbs (provides a short delay to open the ThinkVantage dialogue window, otherwise the following scripts fail because they are sent too soon):
Wscript.Sleep Wscript.Arguments(0) * 1000
AppActivate.vbs (puts focus on the ThinkVantage Password change dialogue window so that Tab and Enter commands are not sent elsewhere with undesired effects):
CreateObject("WScript.Shell").AppActivate "ThinkVantage Password Manager"
SendKeys.vbs (sends a ‘No' response to the PM request to change its KeePass entry):
CreateObject("WScript.Shell").SendKeys "{TAB}{ENTER}"
Please substitute ) where you see smileywink: in the vbs scripts above - I can't get this forum window to stop automatically translating the " ) sequence of text (without a space) as an emoticon.
This batch file approach should work with additional startup switches for KeePass, for example the /backup.path: switch used by ‘another backup' plugin (or you can use the db_backup plugin that works from the KeePass.ini file). Quotes are needed around any entry with spaces. But some things that ‘should work' such as just writing "KeePass.exe" instead of the full path in line 4 of the batch file do not give the same outcome for me. This may be an effect on timing of the switch of focus between windows - so if you strike a problem it may be worth experimenting with the delay time set through the sleep script.
If you set KeePass to lock when minimised, you will have to deal manually with the PM changed-password dialogue every time you re-access KeePass. So it is simpler to close rather than minimise KeePass after each use and restart it when needed, via the batch file.
(iii) You have to tell PM ‘No' whenever it offers to save an entry that is edited in KeePass. This is less of a nuisance, because entries rarely need to be edited once set up in Keepass. There is no way to turn off this requirement. If you select ‘Never' it will prevent use of PM and therefore fingerprint entry to start KeePass (not just the edit window).
(iv) Turn off internet login within PM. This will leave all internet logins to KeePass. Unfortunately you can not set PM to only allow a single program login (KeePass), but you can set it to exclude specific programs, so do that for other programs that you access via KeePass.
(v) Finally, set PM security within CSS so that a fingerprint (or a password if the fingerprint reader fails) is needed every time PM is launched (not just once per boot). Similarly, set KeePass security this way within PM. Otherwise (if you set the requirement to once per boot) your passwords are open to inspection while you are away from your booted computer.
Caution: How secure is your Windows login password? Most likely this is also your PM login password, so it now allows access to your KeePass database! Make sure that it is a unique, secure and preferably memorable password.
How close are we now to the desired combination of security and convenience?
Click on the KeePass shortcut to the batch file given above, swipe the fingerprint, wait while CSS works, then click on the relevant Keepass entry to access any password-protected site or application in your Keypass list - great convenience.
Security is very strong - both KeePass and PM are extremely secure unless you use a weak or insecure master password or select less secure settings.
Starting (or opening a locked instance of) KeePass without the batch file given above requires a couple of extra carefully-placed clicks in the process to tell PM not to mess up its entry for KeePass, then to complete KeePass startup. This is less convenient, and a mistake could prevent future database access - so the batch file method is recommended.
A final caution (while enjoying secure & convenient logins):
Beware - fingerprint access is so convenient that you may forget your master passwords! Eventually they will be needed! You may click the wrong button in PM, suffer a faulty fingerprint reader or change computers! Then you must recall your master passwords before you can access your password file (and possibly your computer). This could be devastating: loss of all secure password information in KeePass and PM (and possibly loss of all information on a protected computer drive, not to mention need to pay for a computer motherboard and HDD replacement). So:
1. Choose very secure but ‘unforgettable' master passwords for KeePass and computer (PM) access.
2. Always set up a secure master password as an alternative to biometric authentication (in case of a faulty fingerprint reader).
3. Keep your password database backups, and your separate master password backups, in another secure (preferably encrypted) but accessible location!
Program versions tested:
KeePass v1.14 (v2 betas not tested) with KeeForm v2 and DB_Backup v1.14
Lenovo CSS v8.20 with PM v3.00
The solutions were tested in November 2008 on a Thinkpad X61 running Windows Vista Business. The tricks to interface with KeePass can vary between fingerprint programs (search the KeePass forum).
Message Edited by r_g_b on 11-03-2008 07:01 PM
Message Edited by r_g_b on 11-04-2008 12:00 AMI'm reviving quite an old topic here, but I have been unable to find any other good information on this. I currently use the latest version of Keepass v2.23 and have Lenovo Passoword Manager v4.3 installed on my new W530 laptop. I can't get PM to recognize any passowords at all, in web browsers or in windows application.
In PM the only thing I can do is create folders and secure notes. My fingerprint software works great for automated logins to windows. Does anyone have any experience with using the fingerprint reader with a windows application like Keepass?
How can I get the Password manager to do ... anything? Recognize a password in windows or a web browser?
I'm open to any other software to be used or I can write scripts if necessary to accomplish this. It doesn't seem like this should be so difficult, but from what I've learned about Lenovo so far, is that nothing is easy. After trying to get battery charge thresholds working proplery in Windows 8, I've already lost faith in a company that I thought had a great reputation. -
well after some weeks of playing I have 2 applescripts that are scripted to give PVR like features to a eyetv equiped mac.
2 scripts are published here:
1) radiotimes - download all of the freeview channel information from the publicaly available radiotimes.com website, generate "listing" type channel information and search these listings for user specified programs (by title), then automatically insert these programms into the eyetv schedule.
2) monitoreyetv - a script that looks at the eyetv task every 5 mins or so, then sleeps the mac when the eyetv task falls below 5% of the processor useage.
so by setting eyetv to wake the mac from sleep automatically and running my monitor eyetv script we have a system that will sleep-wake-sleep when a programm needs recording.
by running the radiotimes script periodically (2 weeks worth of listings are processed at a time) we can automatically "series link" a programm we are interested in.
interested?????
here we go:
-- radiotimes (series link) script:
property download_folder : ((path to desktop) as text) &
"scripts:data:"
property BBC1downloadpath :
"http://xmltv.radiotimes.com/xmltv/94.dat"
property BBC2downloadpath : "http://xmltv.radiotimes.com/xmltv/
107.dat"
property BBC3downloadpath :
"http://xmltv.radiotimes.com/xmltv/45.dat"
property BBC4downloadpath :
"http://xmltv.radiotimes.com/xmltv/47.dat"
property ITVdownloadpath : "http://xmltv.radiotimes.com/xmltv/30.dat"
property ITV2downloadpath : "http://xmltv.radiotimes.com/xmltv/
185.dat"
property ITV3downloadpath : "http://xmltv.radiotimes.com/xmltv/
1859.dat"
property ITV4downloadpath : "http://xmltv.radiotimes.com/xmltv/
1961.dat"
property CH4downloadpath :
"http://xmltv.radiotimes.com/xmltv/132.dat"
property E4downloadpath : "http://xmltv.radiotimes.com/xmltv/158.dat"
property E4P1downloadpath : "http://xmltv.radiotimes.com/xmltv/
1161.dat"
property MORE4downloadpath : "http://xmltv.radiotimes.com/xmltv/
1959.dat"
property MORE4P1downloadpath : "http://xmltv.radiotimes.com/xmltv/
1972.dat"
property FILM4downloadpath : "http://xmltv.radiotimes.com/xmltv/
160.dat"
property FIVEdownloadpath : "http://xmltv.radiotimes.com/xmltv/
134.dat"
property SKY3downloadpath : "http://xmltv.radiotimes.com/xmltv/
1963.dat"
property CBBCdownloadpath : "http://xmltv.radiotimes.com/xmltv/
482.dat"
property CBEESdownloadpath : "http://xmltv.radiotimes.com/xmltv/
483.dat"
property CITVdownloadpath : "http://xmltv.radiotimes.com/xmltv/
1981.dat"
set BBC1downloadURL to BBC1downloadpath
set BBC2downloadURL to BBC2downloadpath
set BBC3downloadURL to BBC3downloadpath
set BBC4downloadURL to BBC4downloadpath
set ITVdownloadURL to ITVdownloadpath
set ITV2downloadURL to ITV2downloadpath
set ITV3downloadURL to ITV3downloadpath
set ITV4downloadURL to ITV4downloadpath
set CH4downloadURL to CH4downloadpath
set E4downloadURL to E4downloadpath
set E4P1downloadURL to E4P1downloadpath
set MORE4downloadURL to MORE4downloadpath
set MORE4P1downloadURL to MORE4P1downloadpath
set FIVEdownloadURL to FIVEdownloadpath
set FILM4downloadURL to FILM4downloadpath
set SKY3downloadURL to SKY3downloadpath
set CBBCdownloadURL to CBBCdownloadpath
set CBEESdownloadURL to CBEESdownloadpath
set CITVdownloadURL to CITVdownloadpath
set BBC1filepath to download_folder & "BBC1.dat"
set BBC2filepath to download_folder & "BBC2.dat"
set BBC3filepath to download_folder & "BBC3.dat"
set BBC4filepath to download_folder & "BBC4.dat"
set ITVfilepath to download_folder & "ITV.dat"
set ITV2filepath to download_folder & "ITV2.dat"
set ITV3filepath to download_folder & "ITV3.dat"
set ITV4filepath to download_folder & "ITV4.dat"
set CH4filepath to download_folder & "CH4.dat"
set E4filepath to download_folder & "E4.dat"
set E4P1filepath to download_folder & "E4P1.dat"
set MORE4filepath to download_folder & "MORE4.dat"
set MORE4P1filepath to download_folder & "MORE4P1.dat"
set FILM4filepath to download_folder & "FILM4.dat"
set FIVEfilepath to download_folder & "FIVE.dat"
set SKY3filepath to download_folder & "SKY3.dat"
set CBBCfilepath to download_folder & "CBBC.dat"
set CBEESfilepath to download_folder & "CBEES.dat"
set CITVfilepath to download_folder & "CITV.dat"
tell application "URL Access Scripting"
set BBC1_dat to download BBC1downloadURL to file BBC1filepath
replacing yes
set BBC2_dat to download BBC2downloadURL to file BBC2filepath
replacing yes
set BBC3_dat to download BBC3downloadURL to file BBC3filepath
replacing yes
set BBC4_dat to download BBC4downloadURL to file BBC4filepath
replacing yes
set ITV_dat to download ITVdownloadURL to file ITVfilepath
replacing yes
set ITV2_dat to download ITV2downloadURL to file ITV2filepath
replacing yes
set ITV3_dat to download ITV3downloadURL to file ITV3filepath
replacing yes
set ITV4_dat to download ITV4downloadURL to file ITV4filepath
replacing yes
set CH4_dat to download CH4downloadURL to file CH4filepath
replacing yes
set E4_dat to download E4downloadURL to file E4filepath
replacing yes
set E4P1_dat to download E4P1downloadURL to file E4P1filepath
replacing yes
set MORE4_dat to download MORE4downloadURL to file MORE4filepath
replacing yes
set MORE4P1_dat to download MORE4P1downloadURL to file
MORE4P1filepath replacing yes
set FILM4_dat to download FILM4downloadURL to file FILM4filepath
replacing yes
set FIVE_dat to download FIVEdownloadURL to file FIVEfilepath
replacing yes
set SKY3_dat to download SKY3downloadURL to file SKY3filepath
replacing yes
set CBBC_dat to download CBBCdownloadURL to file CBBCfilepath
replacing yes
set CBEES_dat to download CBEESdownloadURL to file CBEESfilepath
replacing yes
set CITV_dat to download CITVdownloadURL to file CITVfilepath
replacing yes
end tell
set fileRef to open for access BBC1filepath
set BBC1_dat to read fileRef
close access the fileRef
set fileRef to open for access BBC2filepath
set BBC2_dat to read fileRef
close access the fileRef
set fileRef to open for access BBC3filepath
set BBC3_dat to read fileRef
close access the fileRef
set fileRef to open for access BBC4filepath
set BBC4_dat to read fileRef
close access the fileRef
set fileRef to open for access ITVfilepath
set ITV_dat to read fileRef
close access the fileRef
set fileRef to open for access ITV2filepath
set ITV2_dat to read fileRef
close access the fileRef
set fileRef to open for access ITV3filepath
set ITV3_dat to read fileRef
close access the fileRef
set fileRef to open for access ITV4filepath
set ITV4_dat to read fileRef
close access the fileRef
set fileRef to open for access CH4filepath
set CH4_dat to read fileRef
close access the fileRef
set fileRef to open for access E4filepath
set E4_dat to read fileRef
close access the fileRef
set fileRef to open for access E4P1filepath
set E4P1_dat to read fileRef
close access the fileRef
set fileRef to open for access MORE4filepath
set MORE4_dat to read fileRef
close access the fileRef
set fileRef to open for access MORE4P1filepath
set MORE4P1_dat to read fileRef
close access the fileRef
set fileRef to open for access FILM4filepath
set FILM4_dat to read fileRef
close access the fileRef
set fileRef to open for access FIVEfilepath
set FIVE_dat to read fileRef
close access the fileRef
set fileRef to open for access SKY3filepath
set SKY3_dat to read fileRef
close access the fileRef
set fileRef to open for access CBBCfilepath
set CBBC_dat to read fileRef
close access the fileRef
set fileRef to open for access CBEESfilepath
set CBEES_dat to read fileRef
close access the fileRef
set fileRef to open for access CITVfilepath
set CITV_dat to read fileRef
close access the fileRef
on writeto_file(thisdata, target_file, append_data)
try
set the target_file to the target_file as text
set the opentargetfile to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the opentargetfile to 0
write this_data to the opentargetfile starting at eof
close access the opentargetfile
return true
on error
try
close access file target_file
end try
return false
end try
end writetofile
-- set up listing files
on setuplisting(name)
set prog_listing to ((path to desktop) as text) &
"scripts:listings:" & name & "_listing"
writetofile(("steve's " & name & " listing"), prog_listing, false)
writetofile((ASCII character 10), prog_listing, true)
writetofile(("**************************"), prog_listing, true)
writetofile((ASCII character 10), prog_listing, true)
end setuplisting
--display dialog numberoflines
on update_listing(listing, prog, numberoflines)
set restore to AppleScript's text item delimiters
set AppleScript's text item delimiters to "~"
repeat with i from 1 to numberoflines
--display dialog item i of BBC1_progs
set fields to text items of (item i of prog)
set ptitle to item 1 of fields
set pdes to item 18 of fields
set pstart to item 21 of fields
set pend to item 22 of fields
set pdate to item 20 of fields
set pdur to item 23 of fields
writetofile(ptitle, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile(pdes, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile(pstart, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile(pend, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile(pdate, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile(pdur, listing, true)
writetofile((ASCII character 10), listing, true)
writetofile((ASCII character 10), listing, true)
end repeat
set AppleScript's text item delimiters to restore
end update_listing
on progsearch(findme, prog, numberoflines, channel,
Channel_display)
set restore to AppleScript's text item delimiters
set AppleScript's text item delimiters to "~"
repeat with i from 1 to numberoflines
set fields to text items of (item i of prog)
set ptitle to item 1 of fields
set pdes to item 18 of fields
set pstart to item 21 of fields
set pend to item 22 of fields
set pdate to item 20 of fields
set pdur to item 23 of fields
set prog_date to (date pdate) as text
set recorddatetime to (get text 1 through ((length of prog_date)
- 8) of prog_date) & pstart & ":00"
set channeltorecord to channel as integer
if ptitle = find_me then
display dialog ("Channel: " & Channel_display & (ASCII character
10) & "Date: " & recorddatetime & (ASCII character 10) & "Title: "
& ptitle & (ASCII character 10) & "Descripition: " & pdes & (ASCII
character 10) & "Start time: " & pstart & (ASCII character 10) &
"Finish time: " & pend & (ASCII character 10) & "Duration: " & pdur)
buttons {"Record", "Don't Record", "Cancel"} default button 1 with
icon stop
set buttonreturn to button returned of result as string
if buttonreturn = "Record" then
tell application "EyeTV"
make new program with properties {start time:date
recorddatetime, duration:(pdur * 60) as integer, title:ptitle as
text, description:pdes as text, channel number:channeltorecord}
end tell
end if
end if
end repeat
set AppleScript's text item delimiters to restore
end prog_search
-- create listing for BBC1
set BBC1_progs to get text of paragraphs in BBC1_dat
set numberoflines to count paragraphs in BBC1_dat
set BBC1_listing to ((path to desktop) as text) &
"scripts:listings:BBC1_listing"
my setuplisting("BBC1")
my updatelisting(BBC1listing, BBC1_progs, numberoflines - 1)
-- first programme to search for (eastenders on BBC1)
display dialog " Search For Eastenders ? " buttons {"Yes", "No",
"Cancel"} default button 1 with icon stop
set buttonreturn to button returned of result as string
if buttonreturn = "yes" then
my prog_search("Eastenders", BBC1_progs, numberoflines - 1, 1,
"BBC1")
end if
-- monitoreyetv (auto sleep) script:
-- all debug text left in!!!!! very scruffy
-- script does:
-- 1) wait 5 mins from start
-- 2) then in an infinite loop:
-- a) take 3 samples of the eyetv process at 1 min intervals
-- b) average 3 eyetv cpu samples and check if average is greater than 5 %
-- c) if average > 5 (still recording) then go back to a) else carry on
-- d) wait 5 mins, check the cpu is still less than 5 (new show could have started recording!!!)
-- E) if cpu still less than 5 then sleep
on writeto_file(thisdata, target_file, append_data)
try
set the target_file to the target_file as text
set the opentargetfile to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the opentargetfile to 0
write this_data to the opentargetfile starting at eof
close access the opentargetfile
return true
on error
try
close access file target_file
end try
return false
end try
end writetofile
on setuplog(name)
set prog_log to ((path to desktop) as text) & "scripts:" & name &
"_log"
writetofile(("steve's " & name & " log"), prog_log, false)
writetofile((ASCII character 10), prog_log, true)
writetofile(("**************************"), prog_log, true)
writetofile((ASCII character 10), prog_log, true)
end setuplog
my setuplog("monitor_eyeTV")
set prog_log to ((path to desktop) as text) & "scripts:" &
"monitor_eyeTV" & "_log"
--delay 300
set today to current date
writetofile((" Log File initiated at " & today), prog_log, true)
writetofile((ASCII character 10), prog_log, true)
repeat
delay 300
set check to false
repeat while check is false
set running_tot to 0
set fred to do shell script "ps -xo \"pcpu command\" | grep /
Applications/EyeTV.app/Contents/MacOS/EyeTV" as text
set AppleScript's text item delimiters to space
set Eyetv_cpu to words of fred
--display dialog fred as text
set cpu to item 1 of Eyetv_cpu
--display dialog cpu as text
set running_tot to running_tot + cpu
delay 60
set fred to do shell script "ps -xo \"pcpu command\" | grep /
Applications/EyeTV.app/Contents/MacOS/EyeTV" as text
set AppleScript's text item delimiters to space
set Eyetv_cpu to words of fred
--display dialog fred as text
set cpu to item 1 of Eyetv_cpu
--display dialog cpu as text
set running_tot to running_tot + cpu
delay 60
set fred to do shell script "ps -xo \"pcpu command\" | grep /
Applications/EyeTV.app/Contents/MacOS/EyeTV" as text
set AppleScript's text item delimiters to space
set Eyetv_cpu to words of fred
--display dialog fred as text
set cpu to item 1 of Eyetv_cpu
--display dialog cpu as text
set running_tot to running_tot + cpu
set running_tot to running_tot / 3
set cpu to running_tot
if (cpu as number) < 5 then
--display dialog "EyeTv finished"
set today to current date
writetofile(("1 CPU for EyeTv @ " & today & " is " & cpu),
prog_log, true)
writetofile((ASCII character 10), prog_log, true)
set check to true
else
writetofile(("1 Tried CPU for EyeTv @ " & today & " is " & cpu &
" But was busy"), prog_log, true)
writetofile((ASCII character 10), prog_log, true)
end if
end repeat
delay 300
set today to current date
set fred2 to do shell script "ps -xo \"pcpu command\" | grep /
Applications/EyeTV.app/Contents/MacOS/EyeTV" as text
set AppleScript's text item delimiters to space
set Eyetv_cpu2 to text items of fred2
--display dialog fred as text
set cpu2 to item 1 of Eyetv_cpu2
--display dialog cpu as text
if (cpu2 as number) < 5 then
set today to current date
writetofile(("2 CPU for EyeTv @ " & today & " is " & cpu2),
prog_log, true)
writetofile((ASCII character 10), prog_log, true)
delay 60
tell application "Finder" to sleep
else
writetofile(("2 Tried CPU for EyeTv @ " & today & " is " & cpu2 &
" But was busy"), prog_log, true)
writetofile((ASCII character 10), prog_log, true)
end if
end repeat
well its all a bit scruffy at the moment, but it has all worked for about the past 4 weeks
feel free to comment and use as you see fit.
Steve
mini Mac OS X (10.4.7) ipod mini, several firewire disks, bluetooth keyboard and mouse, eyetvHi Steven
I've been playing around with your first script in this post & re-hashed it because I didn't like the idea of writing code for specifically each channel as they become available. So below is what I came up with (minus your part for searching for particular programs and setting eyeTV).
In my view this will allow users to just change a few things at the top of the script, rather than add blocks of code in the body for each channel. Downside is that the 'ChannelIDs' and 'ChannelSource' (the channels and specific web page) need to be accurately defined in the 'set' statements.
Hope this is of value.
It is as follows;
(* Listings Script -
Most of this script is a re-hashed version of Steven Priggs 'radiotimes (series link)' script
at http://discussions.apple.com/thread.jspa?messageID=3239292#3239292
If it doesn't work - you have only me to blame *)
on run {}
-- establish main variables
set listingsURL to "http://xmltv.radiotimes.com/xmltv/"
set ChannelIDs to {"BBC1", "BBC2", "BBC3", "BBC4", "ITV", "ITV2", "ITV3", "ITV4", "CH4", "E4", "E4P1", "MORE4", "MORE4P1", "FILM4", "FIVE"}
set ChannelSource to {"94", "107", "45", "47", "30", "185", "1859", "1961", "132", "158", "1161", "1959", "1972", "160", "134"}
set downloadPath to ((path to desktop) as text)
set listingsFolder to "TV Listings"
set dataFolder to "Data"
-- make sure the destination folder exists
set thePath to ((path to desktop) as text)
tell application "Finder"
if folder ((downloadPath & listingsFolder & ":") as string) exists then -- check for the folder at the expected location
-- do nothing, it exists doesn't it? What more do you want?
else
set NewFolder to make new folder at folder thePath
set name of NewFolder to listingsFolder
set NewFolder to make new folder at folder ((downloadPath & listingsFolder & ":") as string)
set name of NewFolder to dataFolder
end if
end tell
-- set up download paths
set dataDownloadPath to ((downloadPath & listingsFolder & ":" & dataFolder & ":") as string)
set listingsDownloadPath to ((downloadPath & listingsFolder & ":") as string)
-- cycle through each of the channels
repeat with i from 1 to the count of ChannelIDs
-- set the specific listing page URL for the channel
set DownloadURL to listingsURL & item i of ChannelSource & ".dat"
-- set the path and file name for the downloaded data
set CurrentChannel to item i of ChannelIDs as string
set filePath to dataDownloadPath & CurrentChannel & ".dat"
-- download the page
tell application "URL Access Scripting" to set dataFile to download DownloadURL to file filePath replacing yes
-- save the data in the file
set fileRef to open for access filePath
set dataFile to read fileRef
close access the fileRef
-- create listing files
set ListOfProgs to get text of paragraphs in dataFile
set NumberOfLines to count paragraphs in dataFile
set listingPath to listingsDownloadPath & CurrentChannel & "_listing"
-- setup the header details
writeToFile(("Your Name's " & CurrentChannel & " listing"), listingPath, false)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(("**************************"), listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
-- write the individual listings to the file
my updateListing(listingPath, ListOfProgs, NumberOfLines - 1)
end repeat
end run
-- This handler adds the data to the listings file
on writeToFile(thisData, listingPath, appendData)
try
set the listingPath to the listingPath as text
set the openlistingPath to open for access file listingPath with write permission
if appendData is false then set eof of the openlistingPath to 0
write thisData to the openlistingPath starting at eof
close access the openlistingPath
return true
on error
try
close access file listingPath
end try
return false
end try
end writeToFile
on updateListing(listingPath, ListOfProgs, NumberOfLines)
set restore to AppleScript's text item delimiters
set AppleScript's text item delimiters to "~"
repeat with i from 1 to NumberOfLines
set fields to text items of (item i of ListOfProgs)
set progTitle to item 1 of fields
set progDescr to item 18 of fields
set progStart to item 21 of fields
set progEnd to item 22 of fields
set progDate to item 20 of fields
set progDur to item 23 of fields
writeToFile(progTitle, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(progDescr, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(progStart, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(progEnd, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(progDate, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile(progDur, listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
writeToFile((ASCII character 10), listingPath, true)
end repeat
set AppleScript's text item delimiters to restore
end updateListing -
Is the suspend2 kernel necessary for pm-utils to work? If not, can anyone offer any insight as to why the hibernate and sleep scripts just blank the screen and then do nothing? (computer is unresponsive)
I've got some problems of my own, and I would greatly appreciate any assistance. I've got a suspend2 kernel (even though I guess it isn't necessary), acpi, acpid, cpufreq/cpufreqd, pm-utils and laptop-mode installed, and I get a blank, unresponsive screen when I try to run pm-hibernate. Here is my log:
[root@styx alex]# cat /var/log/pm-suspend.log
Thu Oct 4 18:21:38 CDT 2007: running hibernate hooks.
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/00clear =====
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/01grub =====
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/05led =====
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/10NetworkManager =====
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/20video =====
===== Thu Oct 4 18:21:38 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/49bluetooth =====
===== Thu Oct 4 18:21:39 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/50modules =====
===== Thu Oct 4 18:21:39 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/55battery =====
===== Thu Oct 4 18:21:39 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/60sysfont =====
===== Thu Oct 4 18:21:39 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/65alsa =====
===== Thu Oct 4 18:21:39 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/90clock =====
===== Thu Oct 4 18:21:40 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/94cpufreq =====
===== Thu Oct 4 18:21:40 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/95led =====
===== Thu Oct 4 18:21:40 CDT 2007: running hook: /usr/lib/pm-utils/sleep.d/99video =====
Thu Oct 4 18:21:40 CDT 2007: done running hibernate hooks.
/usr/lib/pm-utils/functions: line 128: /sys/power/disk: Permission denied
Indeed, there is no "disk" file in /sys/power/, which is clearly a problem. What should I do? -
PM-utils, WICD and KDEmod3
Hello folks,
Is there any way to integrate the pm-utils suite in Kdemod 3 instead of using the default acpi handler scripts?
Also, when I resume from sleep with PM-Utils, WICD never seems to be able to reconnect to my network. The tray icon just disappears. When I load it again, it fails to connect and I need to reboot to make it work.
Any input?
Thanks,
Pierre-AlexandreI wrote a hook about oss4 and mpd:
#!/bin/bash
case $1 in
hibernate)
echo "Killing mpd and stopping oss4"
mpd --kill & /etc/rc.d/oss-linux-free stop
suspend)
echo "Killing mpd and stopping oss4"
mpd --kill & /etc/rc.d/oss-linux-free stop
thaw)
echo "Starting oss4 and mpd"
/etc/rc.d/oss-linux-free start & mpd
resume)
echo "Starting oss4 and mpd"
/etc/rc.d/oss-linux-free start & mpd
*) echo "Wrong call"
Create a file /etc/pm/sleep.d/66oss_mpd and put that text in it. Note that the file MUST start with 66 (That's the order sleep scripts are executed in)
Than chmod +x /etc/pm/sleep.d/66oss_mpd and voila Now when the computer goes to sleep it kills mpd and stops oss4 and on resume it starts oss4 and starts mpd.
P.P.Just remove the mpd part if you don't use mpd... -
[SOLVED]Shutdown fails, probably because of some config file I changed
Right, i can't shutdown or reboot properly (pm-util's suspend works).
When I try, all (or most, I can't tell) of the deamons are closed properly, but then something attempts to do something with slimlock. It loops so fast I cant' really read the error
message, but I don't think slimlock is even suposed to be accessed at that point.
Deleting slimlock doesn't help, it just gives a "couldn't find command slimlock" (or something similar) error instead.
I have some vague idea that I'm to blame this, because I seem to remember messing around with the shutdown process, trying to get it to call slimlock before anything else.
The thing is; I don't remember.
From now on I'll keep some file with a log of changes I make to scripts and config files, to make this easier, but this time I really need help finding out what the heck I've done : )
Last edited by Bladtman242 (2012-03-10 01:48:46)I've commented the bash scripts out, and the problem persists.
So I figured I could "limit" the search to
find / -mtime -14 -and -size -2M -exec grep -lisE ".*slimlock.* {} \;"
It turned out to be a "sleep" script in /bin.
I still have no idea why that was called, but I'm marking the thread as solved
Thanks for your efforts
Last edited by Bladtman242 (2012-03-10 01:42:56) -
[solved] my script in /usr/lib/systemd/system-sleep/ was erroneous
Maybe I just didn't see something I need to do...
I have this script:
-rwxr-xr-x 1 root root 322 13. Nov 10:13 /usr/lib/systemd/system-sleep/resume.sh*
And whether I suspend with the kde suspend thingy or with systemctl suspend, this script does not run on resume from suspend.
The script looks like this:
#!/bin/bash
case $1/$2 in
pre/*)
exit 0
# some lines to put graphics card back to sleep with vgaswitcheroo
esac
Did i do something wrong or do I need to do something else?
Last edited by Cdh (2012-11-19 00:58:54)I did some further testing with my system, it appears that using the '*)' specifically causes a "Job for suspend.target canceled" on resume, which could be the problem you are facing. It could also be that the syntax for the pre and post are explicitly given, otherwise I don't see a reason why would it print that message.
Given the code:
#!/bin/sh
#can also be /bin/bash
case $1/$2 in
echo "a $1 with $2"
esac
Works and does not produce the above (red) message.
However combining "pre/*)" and "*)" generates the message, regardless of the shell.
I was doing all the suspends with systemctl suspend
So I'd suggest putting a lot of echo statements in your script and then observe the output of journalctl -b -u systemd-suspend (this is where the echo statements get logged) and check for any errors it might throw. And try to use the pre/*) post/*) if you didn't try that yet.
EDIT:
Forgot to mention I was doing all this as root
Last edited by ytech (2012-11-18 20:46:34) -
[SOLVED] calling sleep from an awk script
I am working on an awk script which repeatedly does some work and then sleeps. Most of the time it is sleeping and while it is sleeping I would like to be able to hit control-c to abort the program. Example awk scripts I have seen suggest this should be possible by testing for a non-zero exit code from the sleep call. However, it doesn't work and my program won't let me stop it. The following test program prints "0" whether I abort the sleep with control-c or wait for it to terminate normally:
#!/bin/awk -f
BEGIN {
print system("sleep 10")
My arch system is up to date. From the "info" man page for sleep it says an abnormal termination should yield a non-zero exit code. I've tried calling other programs instead of sleep and they return non-zero exit codes when I hit control-c on them. I've tried invoking as "/bin/sleep 10" and "env sleep 10" as well. Nothing works. Any idea what I'm doing wrong?
Last edited by scottfial (2010-07-09 08:05:35)Sleep must return something useful when you it ^C because the following lua program:
#!/usr/bin/lua
local exit_code
repeat
exit_code = os.execute("sleep 10")
print("exit_code: " .. exit_code)
until exit_code ~= 0
produces the following output if I let the sleep expire twice and then hit ^C:
exit_code: 0
exit_code: 0
^Cexit_code: 2
and then it terminates. Now here's an equivalent awk program:
#!/bin/awk -f
BEGIN {
do {
exit_code = system("sleep 10")
print "exit_code: " exit_code
} while (!exit_code)
It produces the following if I let the sleep expire twice and then hit ^C twice:
exit_code: 0
exit_code: 0
^Cexit_code: 0
^Cexit_code: 0
and it never terminates. I have to kill it. Just to make sure that awk is seeing exit codes, I compiled this C program
int main(int argc, char *argv[]) {
return 2;
and changed my awk program to call "a.out" rather than "sleep 10". The result is
exit_code: 2
and then it terminates.
I got the following on the command line:
$ ./a.out
$ echo $?
2
$ sleep 10
^C
$ echo $?
130
Excuse me? 130? Lua saw a 2. None of this makes sense. Its as if awk has singled out "sleep" to not work! Where am I going wrong?
Last edited by scottfial (2010-06-22 17:18:54) -
Script lines to stop machine from sleeping while a script is running
I have a long script (in time that is) and sometimes the machine goes to sleep while it is running, thus halting the script. Is there a line I can add to a script that keeps the machine awake while the script runs?
so is there a way around is? how do I stop the computer going to sleep while the script runs? Or how do I protect password etc if using a script with a password in it?
There are a number of approaches. One is to encrypt/obfuscate the password within the script, decoding it on the fly.
Another is to store the password in the user's keychain and have the script retrieve it from there at runtime (this requires a lot more coding to capture the password on the first run, save it to the keychain and retrieve it later).
Another option may be to edit sudoers to allow the target command to be run without authentication, although this opens a whole slew of other potential issues, of course.
Of the three, for a program I don't expect to distribute, I'd probably go for the first option. Note that there are many ways of doing this, ranging from the trivial to the herculean - you'll need to decide how much is appropriate for your needs. One very simple approach (not recommended for high security needs) is just to put your password in a list - the data format of the list makes it more difficult than a string to extract from a read-only script, but it's only one line of AppleScript:
property pw: {"p", "a", "s", "s", "w", "o", "r", "d"}
set my_pw to pw as text
You could get a little more complex by reordering the characters:
property pw: {"d", "r", "o", "w", "s", "s", "a", "p"}
set my_pw to reverse of pw as text
Taking it on a step further, there are all kinds of encryption/transformation algorithms you can apply to further mask the data. Most common algorithms can be translated into AppleScript if needed.
Maybe you are looking for
-
Value is not coming in excise invoice ..
Hi .all, We have created one plant . For that we did STO , delivery , PGI , and billing ( commercial and excise ). But in Excise invoice , excise value is not coming ... Pls Advc ....
-
Symbol pollution between two versions of a library
I am having problems with a library that is calling a function defined within itself from a different version of the library. My company has a core library (let's call it libcore) that handles abstracting across platforms a number of common, low-leve
-
Help! Bw Statistics Problem
I install the BW Statistics follow the How to Dociment. But When I excute the step 9. I can't find the content of info package. How can I handle it? Help Me!
-
PRE/Mac installation errors (was Please Help with PSE 12 Download)
Can anyone help with a .CPP-283 and a .CPP-683 error? [/Adobe/premiere/elements/main/CAHeadless/Make/Mac/../../Src/CAHeadless.cpp-683] [/Adobe/premiere/elements/main/MediaCore/ASL/Foundation/Make/Mac/../../Src/DirectoryRegist ry.cpp-283] I've spen th
-
Having trouble with GoPro files in FCE
I recently shoot an event with two types of cameras. A miniDV Sony and a GoPro camera. These are the specs once I imported into FCE. And the way I imported into FCE was to drag the mpeg4 file from the flash card into FCE. Sony: Frame Size: 720x480 Vi