Author Topic: (solved) sleeptimer in systray  (Read 3107 times)

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3730
  • God knows, i'm not an Angel!
    • Tipps und Tricks
(solved) sleeptimer in systray
« on: September 05, 2010, 02:27:21 PM »
Hello
working on sleeptimer, to display notification in systray.
It will display info in systray, but when i click on the icon it's closed.
My question, how can lock the icon in systray?
It's a zenity script

Code: [Select]
#!/bin/bash
#
#sleeptimer for PCLinuxOS
#created by Leiche for LXDE
#Licence GPL
#Aug Mon 02 20210
#
Encoding=UTF-8
#
# i18n - Internationalization - Internationalisierung
export TEXTDOMAIN=sleeptimer
export TEXTDOMAINDIR="/usr/share/locale"
#
# define some variables - Definierung einiger Variablen
TITLE=sleeptimer
VERSION=0.30
ICON=/usr/share/icons/sleeptimer.png
#DATE=`date +%Y-%m-%d\ %H-%M`
#
#question - Frage
COUNTDOWN=$(zenity --entry --text $"Enter the minutes, to shutdown your systems.\nNotice: One hour is 60 minutes!" --title="$TITLE"" $VERSION" --window-icon=$ICON)
if [ "$COUNTDOWN" = "" ];then
exit
else
TIMER=$(echo $(($COUNTDOWN*60)))
sleep $TIMER | echo sleep $TIMER | zenity --notification --text=$"Sleeptimer is set of $COUNTDOWN minutes!" --window-icon=$ICON

#last change to exit - letzte Möglichkeit den Countdown zu stoppen
(
echo "99" ; sleep 1
echo "90" ; sleep 1
echo "80" ; sleep 1
echo "70" ; sleep 1
echo "60" ; sleep 1
echo "50" ; sleep 1
echo "40" ; sleep 1
echo "30" ; sleep 1
echo "20" ; sleep 1
echo "10" ; sleep 1 ) |
        zenity --progress \
 --window-icon=$ICON \
          --title $"$TITLE""$VERSION" \
          --text=$"Your system will shutdown in 10 seconds.\n<b>To abort click on cancel!</b>" \
          --percentage=0 \
 --auto-close \
 --auto-kill
if [ "$?" = -1 ] ; then
                 zenity --error --text="Aborted by user!"
         fi
#shutdown - Herunterfahren
dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
fi
exit

Thanks for helpful answer  :)
« Last Edit: September 06, 2010, 10:40:31 AM by Leiche »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: sleeptimer in systray
« Reply #1 on: September 05, 2010, 03:06:14 PM »
Perhaps you need to set up a specific display option for when it has been clicked? That is, tell it to open the zenity dialog.


Offline Mark342

  • Sr. Member
  • ****
  • Posts: 334
Re: sleeptimer in systray
« Reply #2 on: September 05, 2010, 03:27:25 PM »
Leiche, you can try something like this:

Code: [Select]
exec 3> >(zenity --notification --window-icon=$ICON --listen)
echo tooltip: $"Sleeptimer is set of $COUNTDOWN minutes!" >&3
sleep $TIMER
exec 3>&-

This is a bit of a hack, and relies on a bug though.
https://bugzilla.gnome.org/show_bug.cgi?id=559848

The bug was filed in 2008 and a patch was posted but it never got reviewed.
Lets hope someone comes up with a better solution.  ;)

The update-notifier zenity script should have a way of doing Neal's solution. So you might want to take a look at that.
« Last Edit: September 05, 2010, 04:39:11 PM by Mark342 »
Anything worth doing is worth overdoing.

Registered Linux user #493318
Register yourself here: Linux Counter

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3730
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: sleeptimer in systray
« Reply #3 on: September 06, 2010, 10:40:00 AM »
Thank you, Mark, that is the trick, now i will add a countdown  ::), maybe later  :)

uncleV

  • Guest
Re: (solved) sleeptimer in systray
« Reply #4 on: September 06, 2010, 10:48:46 AM »
All,
don't forget I have the unique version of sleeptimer that wakes you when it's time to halt the computer.

I believe Leiche lost it.
But I can share...

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: (solved) sleeptimer in systray
« Reply #5 on: September 06, 2010, 11:50:02 AM »
All,
don't forget I have the unique version of sleeptimer that wakes you when it's time to halt the computer.

I believe Leiche lost it.
But I can share...

It wakes you? :o You sleep while using the computer? :o

uncleV

  • Guest
Re: (solved) sleeptimer in systray
« Reply #6 on: September 06, 2010, 12:20:08 PM »
You know...

I sit and think (in front of the computer). After a while I realise I'm only sitting... But if I don't realise that I fall asleep.
So I use this unique version of sleeptimer.

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3730
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: (solved) sleeptimer in systray
« Reply #7 on: September 25, 2010, 07:56:37 AM »
Sitting on my laptop, and play a little with the command date.
I like to display when the system will shutdown.
I and find a solution, but when i type
Code: [Select]
date +%si get  1285422586
This is the seconds from 1970-01-01 until now.
Now i add this seconds with the command
Code: [Select]
date -d "1970-01-01 1285422586 sec"My result Sa 25. Sep 14:49:46 CEST 2010.
Hmm it's failed one hour. What's wrong with it?

uncleV

  • Guest
Re: (solved) sleeptimer in systray
« Reply #8 on: September 25, 2010, 08:02:34 AM »
Summer day-light shift correction?

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3730
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: (solved) sleeptimer in systray
« Reply #9 on: September 25, 2010, 08:06:59 AM »
This could be, what your result when try the command?

uncleV

  • Guest
Re: (solved) sleeptimer in systray
« Reply #10 on: September 25, 2010, 08:12:25 AM »
Quote
date +%s
1285423740

date -d "1970-01-01 1285423740 sec"
Sat Sep 25 15:09:00 EEST 2010

The real time here (Bulgaria, EEST) was 17:09 :-\

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3730
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: (solved) sleeptimer in systray
« Reply #11 on: September 25, 2010, 08:14:14 AM »
So i must find a another way to display.
Thanks for testing...

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: (solved) sleeptimer in systray
« Reply #12 on: September 25, 2010, 08:17:34 AM »
Quote
[neal@localhost ~]$ date +%s
1285427577
[neal@localhost ~]$ date -d "1970-01-01 1285427577 sec"
Sat Sep 25 16:12:57 CDT 2010
[neal@localhost ~]$

This is very far from the correct time. :o It was 10:12 EDT, when I ran this. Hmm...... I must check my settings again. ::)
« Last Edit: September 25, 2010, 08:28:18 AM by Neal »

uncleV

  • Guest
Re: (solved) sleeptimer in systray
« Reply #13 on: September 25, 2010, 08:19:17 AM »
So i must find a another way to display.
Me thinks it gives the (GMT time+local shift) without the day-light saving correction.
You in Germany are +1 hour compared to GMT without summer daylight correction.
Me in Bulgaria is +2 hour compared to GMT without summer daylight correction.

So everything is fine?
« Last Edit: September 25, 2010, 08:22:04 AM by uncleV »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: (solved) sleeptimer in systray
« Reply #14 on: September 25, 2010, 08:23:30 AM »
So i must find a another way to display.
Me thinks it gives the (GMT time+local shift) without the day-light saving correction.
You in Germany are +1 hour compared to GMT without summer daylight correction.
Me in Bulgaria is +2 hour compared to GMT without summer daylight correction.

So everything is fine?

If this is correct, then a way to add the +1, +2 or other +number is needed. Correct?