You are not logged in.

#1 2008-12-20 13:17:52

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

pyStopwatch: a gui stopwatch that can minimize to the tray

Info page: http://xyne.archlinux.ca/projects/pystopwatch

I wrote a gui timer in pyGTK because I couldn't find a nice one (I don't remember exactly how it behaved, but this should be a bit similar to the xfce4-timer-plugin, but without needing a specific panel). Use it to avoid overcooked pizzas or angry girlfriends woken up by loud, annoying (yet thus effective) oven timers. wink

Check the info page for screenshots, alarm command suggestions and where to find the preferences. Usage should be obvious.

Please let me know if there's anything wrong with the dependencies.

Suggestions, comments and feature requests are welcome.

Last edited by Xyne (2018-11-24 21:54:08)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2009-06-21 04:43:02

yvonney
Member
Registered: 2008-06-11
Posts: 671

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

I'm loving it!!! Just found it. So, I may be a bit dyslexic as so off to read the prefs stuff as I really need to find out if there's an alarm! :--)

OK, so minimizing it....hmmm... I use a wm   musca...  Any tips are great though I'll figure it out at some point.

Last edited by yvonney (2009-06-21 04:46:46)

Offline

#3 2009-06-21 04:55:20

lifeafter2am
Member
From: 127.0.0.1
Registered: 2009-06-10
Posts: 1,332

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

yvonney wrote:

I'm loving it!!! Just found it. So, I may be a bit dyslexic as so off to read the prefs stuff as I really need to find out if there's an alarm! :--)

OK, so minimizing it....hmmm... I use a wm   musca...  Any tips are great though I'll figure it out at some point.

If Musca is anything like Xmonad then you don't have anywhere for it to minimize to.  If that is the case you can use trayer:

pacman -S trayer

I use it with Xmonad, pretty simple setup.


#binarii @ irc.binarii.net
Matrix Server: https://matrix.binarii.net
-------------
Allan -> ArchBang is not supported because it is stupid.

Offline

#4 2009-06-21 22:11:50

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

yvonney wrote:

I'm loving it!!! Just found it. So, I may be a bit dyslexic as so off to read the prefs stuff as I really need to find out if there's an alarm! :--)

OK, so minimizing it....hmmm... I use a wm   musca...  Any tips are great though I'll figure it out at some point.

Thanks. Let me know if you have any trouble setting up an alarm command and I'll try to help.
I've never used Musca but the wiki page contains entries in the .musca_start file for stalonetray so that should work too. That's what I use here with Openbox.

That also reminds me that I need to create an icon for pystopwatch.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2009-06-22 00:13:17

yvonney
Member
Registered: 2008-06-11
Posts: 671

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

I use stalonetray which seems to be the most generic for musca etc. though not entirely sure.

So, I have a .musca_start. thanks for thinking.

I'll have to give this a think once the crazy busy slows a bit.   cool!

Offline

#6 2009-06-22 01:25:17

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Ok, I've finally added an icon. I'm not sure if I'll keep it though but it's better than the stock play icon (I hope).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2009-09-19 21:07:32

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

I really like this app, but I cant seem to get the settings to stick.  I set this alarm command

/usr/bin/aplay -q /home/tj/sound-effects/stopwatch.wav &

Whenever I close the program everything reverts back to defaults, which is blank.


EDIT:

I just checked ~/.config/pyStopwatch.conf and the alarm command is correct there, but when I open pystopwatch it doesnt seem to be reading the conf file because its still not working.

Last edited by tjwoosta (2009-09-19 21:24:29)

Offline

#8 2009-09-20 03:51:20

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

@tjwoosta
It should work with the latest version. Apparently pyStopwatch has never loaded the alarm command setting (I somehow skipped it when I wrote the configuration file parser). I can't believe that it was only discovered now. I guess there really are only about 3 people using it, and rarely at that. tongue

Anyway, while I was tinkering around with the code, I've done the following:
* now uses the XDG_CONFIG_HOME environment variable when set
* "%t" in the alarm text will be replaced with the current pystopwatch time
* if the alarm text begins with "#!", the rest of it will be executed as a command and the output will be used as the alarm text
* added a "help" entry to the tray icon's right-click menu which displays the man page
* it now invokes python2 instead of python to ensure future compatibility
* updated the man page


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2009-09-20 04:40:00

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Nice work! I'd love to use this as a workout timer....any chance of getting an intervals function built-in somehow. Set x intervals of y minutes work and y seconds(minutes) rest, with a chime or sound in between each one. I found one python command line timer here and one html/javascript timer you can use locally here. Yours already looks nicer smile

Thanks!
Scott

Offline

#10 2009-09-20 07:08:45

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

After giving the idea of intervals some consideration, I don't see a direct way to add it to the existing code. The logic itself wouldn't be that difficult but the user interface is problematic. I thought of maybe adding a dropdown configuration panel for setting intervals but I think it would jar with the current simple interface.. I also thought of adding command line arguments so that it could be used from a script but that seems clunky.

I'll reconsider it though if I come up with a nice way to do it.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#11 2009-09-20 20:17:56

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Thanks for the update, its working great now smile

Offline

#12 2009-11-19 16:07:32

schef
Member
Registered: 2009-04-16
Posts: 71

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

hej..can you pleas explain me where the config file should be and if there is a way to configer the timer out side the GUI..
exmp: "pystopwatch countdown-a 1m" and then to play something..i didnt get the thing with the options..
i use awesome and i dont have anything on right-clink..
thnx.

Offline

#13 2009-11-19 23:21:54

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

There is no command-line functionality because it would be trivial to write a script to do just about anything that pystopwatch does (e.g. "sleep 300 && mpg123 time.wav"). You're not the first one to ask about that though so I might eventually clean up the code to make the GUI a proper configurable widget for use in other applications, but that is no where near the top of my ToDo list.

The configuration file resides in $XDG_CONFIG_HOME/pystopwatch, which is ~/.config/pystopwatch by default.

I've just updated pystopwatch so that you can access the tray's context menu directly via the GUI by right-clicking on the display frame. Previously it assumed that you had a tray installed (e.g. stalonetray).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#14 2010-02-01 08:53:56

Hide
Member
From: Castalia
Registered: 2007-02-02
Posts: 368

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Sorry for necrobumping, but I just found this nifty bit of software and I adore it. Thanks, Xyne smile

Offline

#15 2010-07-06 19:31:42

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

I think the Timer mode needs to renamed to Stopwatch and the two countdown modes renamed to Timer.

Wikipedia wrote:

Whereas a stopwatch counts upwards from zero for measuring elapsed time, a timer counts down from a specified time interval, like an hourglas

BTW in the font selection dialog, the cancel and ok button do not close the window.

Last edited by anonymous_user (2010-07-06 19:37:00)

Offline

#16 2010-07-06 22:50:43

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

@Hide
Thanks smile

Btw, bumping a project thread is not considered necrobumping.


@anonymous_user
I've changed "timer" to "stopwatch" and "countdown" to "countdown timer" to make it clear. I've also fixed the font selection dialogue and corrected two other noobish pyGTK mistakes.

Last edited by Xyne (2010-07-06 22:51:02)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#17 2010-07-07 00:18:43

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Thanks Xyne. And one more thing: when the pyStopwatch windows comes up (after the timer completes) would it be possible to flash in the taskbar (aka urgency)?

Offline

#18 2010-10-07 06:32:36

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Another request, could an option be added to make pyStopwatch display the current time in 12hr instead of 24hr?

Offline

#19 2010-10-07 18:11:43

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

I considered it and even started implementing it, but adding a 12h mode presents loads of little niggling issues with formatting, and widget alignments, My time at the moment is limited and I'm reluctant to spend it on something that seems so trivial.

Plus there's the ever-present temptation to clean up the code and I'm too easily sidetracked. (You can tell that it's one of the first things I wrote in Python. tongue)

I will probably add it eventually but I don't know when. Sorry.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#20 2018-10-09 01:41:35

likytau
Member
Registered: 2012-09-02
Posts: 142

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Hi,

I recently upgraded to pystopwatch from the defunct CLI tool 'utimer'. I'm pretty happy with pystopwatch so far, and I specifically appreciate the ability to manually alter the H/M/S of the current time (since I occasionally forget to start the stopwatch!).

However, I hate clicking on things, especially small buttons. It would be really nice if the Start/Stop button activated when Enter or Space is pressed; then the user would only need to focus the window ( a much larger target than the button, obviously) and press Enter once to stop/start the timer. A side effect would be that the timer could be started/stopped within a script, using xdotool.

IIRC, passing 'default=True' parameter when constructing the start/stop button, causes it to activate when Enter is pressed.

If you considered also giving a keyboard shortcut to Reset and Mode -- eg. Alt+R, Alt+M, that's IIRC even easier : just insert a mnemonic marker in the label text when constructing the button, eg "Reset" -> "_Reset", and the mnemonic handling takes care of the rest.

One bug report: after the first time bringing up the font selection dialog (successfully), selecting a font, and closing the window, and hitting 'apply and save', successive openings instead produce a small window -- let's say 16x16 px in size -- with nothing in it; the only thing I can do with that window is close it.

EDIT: The above bug is only a minor annoyance, since I can restart pystopwatch in order to access the font selection dialog if needed.

Last edited by likytau (2018-10-10 04:36:54)

Offline

#21 2018-10-09 02:18:29

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

An 8 year bump, almost to the day? I find it highly unlikely that Xyne is working on or maintaining this project. Thanks for a proper post though! Hopefully someone will be able to help you. smile


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#22 2018-10-09 02:25:35

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

JohnBobSmith wrote:

I find it highly unlikely that Xyne is working on or maintaining this project.

Oh?  It's still on Xyne's website.  The AUR package still has Xyne as a maintainer, and it was updated earlier this year.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#23 2018-10-10 05:24:08

likytau
Member
Registered: 2012-09-02
Posts: 142

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Regarding the main issue, in a typical setup,

self.run_button.set_can_default(true)
self.run_button.grab_default()

seems like the correct method to make a widget activate by default. But at least in this setup, it has no effect on which button activates on Enter keypress. The activated widget is always the currently focused widget.

Regarding the secondary issue, adding mnemonics / alt-R|M keyboard shortcuts was as simple as I said; here is a very short diff, probably should be applied using 'patch -p1':

--- a/pystopwatch	2018-10-10 15:09:20.855571955 +1030
+++ b/pystopwatch	2018-10-10 15:47:27.771484050 +1030
@@ -356,7 +356,7 @@
     self.sec.show()
 
     # reset button (alone, for the sake of the layout)
-    self.reset_button = gtk.Button(label='Reset')
+    self.reset_button = gtk.Button(label='_Reset')
     self.reset_button.connect("clicked",self.reset)
     self.reset_button.show()
 
@@ -364,7 +364,7 @@
     self.control_box = gtk.HBox()
     self.control_box.show()
 
-    self.mode_button = gtk.Button(label='Mode')
+    self.mode_button = gtk.Button(label='_Mode')
     self.control_box.add(self.mode_button)
     self.mode_button.connect("clicked",self.toggle_mode)
     self.mode_button.show()

Offline

#24 2018-11-04 04:54:41

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

@likytau
Thanks for the idea and patch. I ended up doing it a little different with the following hotkeys:

  • r and <alt>+r reset,

  • tab and <alt>+o change the mode

  • space toggles start/stop

  • h and H increment and decrement the hour

  • m and M -"- minute

  • s and S -"- second

I spent about 10 minutes unsuccessfully trying to find a way to detect if the alt key was pressed on an "m" key event. I then gave up on using <alt>+m for the mode. If someone finds a solution then I'll update the code.

The update should be up shortly.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#25 2018-11-20 06:19:29

likytau
Member
Registered: 2012-09-02
Posts: 142

Re: pyStopwatch: a gui stopwatch that can minimize to the tray

Nice, thanks for taking the time to implement my idea.  I've tested all those actions and they mostly work well -- space and tab are a bit spotty though, see below.

I spent about 10 minutes unsuccessfully trying to find a way to detect if the alt key was pressed on an "m" key event. I then gave up on using <alt>+m

(EDITED)
I see, so your key-handler is swallowing the M unconditionally, when it really should only do anything when no modifiers are pressed. I'll see what I can find out about that.

Space and Tab currently have a double action. That is, Tab moves keyboard focus between widgets AND cycles mode; Space activates the current widget AND pauses/unpauses (this is particularly funny when the Stop/Start button is focused. I'd guess the action is triggered twice and thus cancels itself out). My guess would be that your signal handler needs to run before the default GTK signalhandler for these events, and prevent subsequent handlers from running (I think this latter thing is done by returning True from the signal handler)

EDIT: BTW, link to project in OP appears to be broken. Corrected link: https://xyne.archlinux.ca/projects/pystopwatch/

EDIT2: OK, double-action fix is really easy; just make handle_key() return True in the branch which invokes handler(). With that, this is really comfortable now IMO.

EDIT3: Alt+m for Mode button works after adding a

if event.state != 0:
    return False

check at the start of handle_key. State seems to represent modifier state (so, 0 if no modifiers are pressed)

Last edited by likytau (2018-11-20 06:57:24)

Offline

Board footer

Powered by FluxBB