I can place this simple script into my home shutdown folder and it functions at shutdown deleting all the *.png pictures.
#!/bin/bash
# used to remove both large and normal thumbnails in /home/user/.thumbnails
# make sure it is executable and place script in /home/user/.kde/shutdown to run at shutdown
rm /home/user/.thumbnails/large/*.png; rm /home/user/.thumbnails/normal/*.png
exit 1 <----- SHOULD BE EXIT 0
fi <----- MISTAKE IN COPY PASTE, REMOVE fi
done <----- NOT NEEDED BAD COPY PASTE AND THE LACK OF ATTENTION
I would like to do the deletion on suspend (to ram , i don't use hibernate ) also but have not had any luck in finding the proper place to either add the script or insert the commands to do the deletion.
Does anyone have any ideas on where to do this?
I've tried placing it in /etc/pm/config.d but it doesn't run and suspend fails.
Is there another place to try?
deleting pictures when suspending laptop on lid close / How?
deleting pictures when suspending laptop on lid close / How?
Last edited by GDixon on Sat Jul 12, 2014 6:26 pm, edited 2 times in total.
Re: deleting pictures when suspending laptop on lid close /
Just make a symbolic link that points the ~/.thumbnails folder to /dev/nullfile. Then you won't have to run any scripts on shutdown or hibernate because the system won't be able to write any thumbnails for you to delete.
MX-14; 3.12-0.bpo.1-686-pae kernel using 4GB RAM
2.4GHz AMD Athlon 4600+
NVidia GeForce 6150 LE; 304.121 Display Driver
You didn't slow down because you're old; you're old because you slowed down.
2.4GHz AMD Athlon 4600+
NVidia GeForce 6150 LE; 304.121 Display Driver
You didn't slow down because you're old; you're old because you slowed down.
Re: deleting pictures when suspending laptop on lid close /
Suspend failing when you add your script indicates that is the right place but there is something wrong with your script. In fact, there are two obvious problems with the script you posted. I copied it to "bad-script" and then ran "bash -n bad-script":GDixon wrote:I've tried placing it in /etc/pm/config.d but it doesn't run and suspend fails.
Is there another place to try?
Code: Select all
bash -n bad-script
bad-script: line 7: syntax error near unexpected token `fi'
bad-script: line 7: `fi'
Re: deleting pictures when suspending laptop on lid close /
Good way to do it Joany but there are times i need to go through the thumbnails, very rare but it has happened.
fixed the thumbnails.sh by removing the fi (oops, should be more careful on copy and paste from my file of script goodies i use.
thumbnails.sh runs great from terminal or shutdown in .kde
Wrote a quick thumbs.sh to place in different places but the same thing happens , suspend starts, locks the screen and resumes right away.
#!/bin/bash
case "$1" in
suspend)
/user/local/bin/thumbnails.sh <------MISTAKE USER SHOULD BE USR
;;
*)
;;
esac
exit $?
above has been placed in /etc/pm/config.d and also tried sleep.d
still fails in the same way but i did catch it in the log when i tried it in /usr/lib/pm-utils/sleep.d
Heres the important part of the log
Running hook /usr/lib/pm-utils/sleep.d/thumbs.sh suspend suspend:
/usr/lib/pm-utils/sleep.d/thumbs.sh: line 4: /user/local/bin/thumbnails.sh: No such file or directory
/usr/lib/pm-utils/sleep.d/thumbs.sh suspend suspend: Returned exit code 127.
Sat Jul 12 15:43:30 EDT 2014: Inhibit found, will not perform suspend
Sat Jul 12 15:43:30 EDT 2014: Running hooks for resume
____________________________
it seems it is telling me it can not locate the thumbnails.sh script so it can run it? Maybe I don't have the line 4 command correct yet?
Any ideas why it can't find it when it is pointed right at it? thumbnails is readable and executable by everyone and only root can write.
fixed the thumbnails.sh by removing the fi (oops, should be more careful on copy and paste from my file of script goodies i use.
thumbnails.sh runs great from terminal or shutdown in .kde
Wrote a quick thumbs.sh to place in different places but the same thing happens , suspend starts, locks the screen and resumes right away.
#!/bin/bash
case "$1" in
suspend)
/user/local/bin/thumbnails.sh <------MISTAKE USER SHOULD BE USR
;;
*)
;;
esac
exit $?
above has been placed in /etc/pm/config.d and also tried sleep.d
still fails in the same way but i did catch it in the log when i tried it in /usr/lib/pm-utils/sleep.d
Heres the important part of the log
Running hook /usr/lib/pm-utils/sleep.d/thumbs.sh suspend suspend:
/usr/lib/pm-utils/sleep.d/thumbs.sh: line 4: /user/local/bin/thumbnails.sh: No such file or directory
/usr/lib/pm-utils/sleep.d/thumbs.sh suspend suspend: Returned exit code 127.
Sat Jul 12 15:43:30 EDT 2014: Inhibit found, will not perform suspend
Sat Jul 12 15:43:30 EDT 2014: Running hooks for resume
____________________________
it seems it is telling me it can not locate the thumbnails.sh script so it can run it? Maybe I don't have the line 4 command correct yet?
Any ideas why it can't find it when it is pointed right at it? thumbnails is readable and executable by everyone and only root can write.
Last edited by GDixon on Sat Jul 12, 2014 6:23 pm, edited 2 times in total.
Re: deleting pictures when suspending laptop on lid close /
Hmmmm could my hard drive be getting shutdown before the scripts can be run?
Re: deleting pictures when suspending laptop on lid close /
/user/local/bin/thumbnails.sh --> /usr/local/bin/thumbnails.sh
I suggest you debug the script by running it from the command line.
There was also a "done" in the original script that needs to be removed.
I suggest you debug the script by running it from the command line.
There was also a "done" in the original script that needs to be removed.
Re: deleting pictures when suspending laptop on lid close /
a fresh set of eyes helps. the usr was correct it was a mistake and the exit 1 on the thumbnails.sh script
needs to be exit 0
I made it exit 0 and placed the thumbs.sh in /usr/lib/pm-utils/sleep.d and reran everything after testing it in a terminal.
Thanks for the fresh set of eyes it helped and now works as expected.
needs to be exit 0
I made it exit 0 and placed the thumbs.sh in /usr/lib/pm-utils/sleep.d and reran everything after testing it in a terminal.
Thanks for the fresh set of eyes it helped and now works as expected.
Last edited by GDixon on Sat Jul 12, 2014 6:29 pm, edited 1 time in total.
Re: deleting pictures when suspending laptop on lid close /
#!/bin/bash
case "$1" in
suspend)
/usr/local/bin/thumbnails.sh
;;
*)
;;
esac
exit $?
place above in /usr/lib/pm-utils/sleep.d and no need to number it like the other scripts in there.
--------------------------------------------------------------------------------------
it calls thumbnails.sh below and make both read, execute for all and write for root only
#!/bin/bash
rm /home/username/.thumbnails/large/*.png; rm /home/username/.thumbnails/normal/*.png
exit 0
case "$1" in
suspend)
/usr/local/bin/thumbnails.sh
;;
*)
;;
esac
exit $?
place above in /usr/lib/pm-utils/sleep.d and no need to number it like the other scripts in there.
--------------------------------------------------------------------------------------
it calls thumbnails.sh below and make both read, execute for all and write for root only
#!/bin/bash
rm /home/username/.thumbnails/large/*.png; rm /home/username/.thumbnails/normal/*.png
exit 0
Re: deleting pictures when suspending laptop on lid close /
What is and where can you get "bad-script" ?
I use -x for testing and it is lacking.
I use -x for testing and it is lacking.
Re: deleting pictures when suspending laptop on lid close /
Will a moderator please put this in the scripts forum/area.
Thank you
Thank you