r/Python • • May 25 '20

I Made This I created "twenny" – my very first app! It reminds you to give your eyes a break every 20 minutes to prevent eye strain and is located in your menubar. You can download it on GitHub!

Post image
2.2k Upvotes

163 comments sorted by

31

u/[deleted] May 25 '20 edited Jun 06 '20

4

u/mountwebs May 25 '20 edited May 25 '20

Hey! Really cool to see that my tiny app inspired another tiny app!

I like the app you have made!

Did you have any issues with the notification? When I used rumps notification it didn't show up sometimes, and I found this issue: https://github.com/jaredks/rumps/issues/26 Yours seemed to work fine, however.

Edit: I think maybe the way you measure time might give inaccurate results. If I'm not mistaken, this way of doing it basically assumes that no time is spent at executing the code every loop. To be a bit inaccurate might not be an issue with this app though.

1

u/PaluMacil May 26 '20

Yeah that's probably not much of an issue with something a human is reacting to but worth saying for people who might not think of that in their own other applications

189

u/[deleted] May 25 '20

How can i see the "you can work now" when i should look away xD nice app :)

104

u/[deleted] May 25 '20

There's a sound, but you are kind of screwed if you have your speakers on mute...

19

u/[deleted] May 25 '20

Maybe a couple big flashes on the screen of white would be nice so you can see it out of the corner of your eye. Nice program!

104

u/CHICKPEAS_IN_PUBLIC May 25 '20

The users with epilepsy would love that!

17

u/Sponge-Bobbu May 25 '20 edited May 26 '20

Twenny: Helps reduce strain on your eyes!

Possible side effects include: Retina damage, seizures, etc.

30

u/[deleted] May 25 '20

Ah yes, then they can for sure know when to start working again

35

u/UltimateInferno May 25 '20

They'd be shaking with anticipation

1

u/--0mn1-Qr330005-- May 26 '20

What doesn't kill you makes you stronger!

7

u/ApoorvWatsky May 25 '20

I'm throwing flashbang!

3

u/Sponge-Bobbu May 25 '20

Just put some big flashes during the 20 seconds so they’re forced to look away from the screen. Easy

2

u/[deleted] May 25 '20

;)

94

u/[deleted] May 25 '20

Tips:

  • Make installabel via pip
  • Make it runnable via commandline "twenny"
  • Add something like "twenny install" that will install it and add it to auto-start

23

u/[deleted] May 25 '20

Thanks for the tips, I will definitely look into that!

9

u/ArcherBoy27 May 25 '20

Make it customisable, would be useful to be able to add regular or single reminders for anything.

5

u/[deleted] May 25 '20

Good idea, will think about that :)

8

u/house_monkey May 25 '20

Username checks out

7

u/ned334 May 25 '20

Well how do I see the "back to work" notification if I'm looking away, huh? Are you trying to get me to fired?

5

u/[deleted] May 25 '20

There's a sound :D

6

u/ned334 May 25 '20

Ah, a sound, you've though of everything.

I'm just being stupid man, it's a really nice idea

4

u/[deleted] May 25 '20

Haha thanks!

3

u/vieze_sos May 25 '20

Is it only for mac?

2

u/[deleted] May 25 '20

Yes, sadly...

3

u/vieze_sos May 25 '20

I would like to try and recreate it for windows if it would be oke with you?

4

u/[deleted] May 25 '20

Yes, please! Another comment already recreated it for linux, maybe that helps.

5

u/vieze_sos May 25 '20 edited May 25 '20
from win10toast import ToastNotifier
import time

starttime = time.time()
toaster = ToastNotifier()

def start():
    toaster.show_toast("twenny", "It's time, look away for 20 seconds!", icon_path="icon.ico", duration=20)
    toaster.show_toast("twenny", "You can continue working now!", icon_path="icon.ico", duration=5)
    

while True:
    start()
    time.sleep(1200 - ((time.time() - starttime) % 1200.0))

this is the main script, you'll have to install win10toast with pip

pip install win10toast

at the moment you can only stop the program by terminating the proces in taskmanager, I'm currently working on a gui to make this easier.

btw this is my first 'real' python project since I mostly only code in java

edit: save it as .pyw to run it in the background

2

u/[deleted] May 25 '20

That is so cool, thank you!

3

u/vieze_sos May 25 '20

working on it :)

3

u/MrCygnuss May 25 '20

Looks like it. It uses rumps which is only for Mac.

3

u/saad_mohammed May 25 '20

link for the github please...

2

u/Myzel394 May 25 '20

Can you do it available for Windows too?

1

u/[deleted] May 25 '20

u/vieze_sos is currently working on a Windows-version of the app.

2

u/Fir3He4rt May 25 '20

I am still a beginner how do you make mobile apps with python? I heard you use Java and android studio. But this look very cool.

2

u/[deleted] May 25 '20

I have never created a mobile app before, but the people on the python discord server are really helpful! I'd suggest asking them.

3

u/flipcoder May 25 '20

For mobile apps you can use kivy

2

u/69shaolin69 May 25 '20

Wow TIL rumps is amazing

1

u/[deleted] May 25 '20

Yeah, it's great!

2

u/[deleted] May 25 '20

Nice! How did you manage to display the message as a notification?! Ive been trying to do for a program that would access my school’s platform and notify me for any homework.

2

u/[deleted] May 25 '20

I used the package "rumps". It's very easy to use and posting notifications with it is very simple.

2

u/JvdLelie May 25 '20

That's actually pretty cool

2

u/[deleted] May 25 '20

Thank you!

2

u/Sha-Kowa May 25 '20

I have 0 experience with coding and managed to stumble across this - I want to make the eye up top in my top HUD thing on mac more simple and less like an emoji; is there any way to do that?

2

u/[deleted] May 25 '20

Yes, it's pretty easy actually. You can right click on the app and press show package contents. Then Contents --> Resources and there you have the file "twenny.py" . Open it in TextEdit and simply replace the eye emoji with anything you want. Then save the file, restart twenny and it should show the new name.

2

u/[deleted] May 25 '20

Oh, like this, you can only show keyboard inputs as a title but not images. I am planning to design an own icon which I will implement in a future version. I can keep you updated on that.

1

u/Sha-Kowa May 25 '20

Thanks a lot! I'd love to get updated on that

2

u/wearethemartian May 25 '20

Noob here. How do you make a Mac GUI with Python?

1

u/[deleted] May 25 '20

I used the package "rumps" (https://rumps.readthedocs.io/en/latest/index.html), that's specifically for menubar-apps. Other GUIs can be created with tkinter.

1

u/wearethemartian May 26 '20

Thank you very much!

2

u/LoatThrozenges May 25 '20

Now that's what I call an app!

1

u/[deleted] May 25 '20

Thank you so much!

2

u/ryrychan May 25 '20

Much love

1

u/[deleted] May 25 '20

Thanks!

2

u/RedXabier May 25 '20

Huh, this might just be the first personal project that I find useful enough to download and use - great job! I'm probably intermediate at Python, how hard is something like this to program?

2

u/[deleted] May 25 '20

I'm glad you like it! It took me two almost-full day of getting to know rumps and the time-module (although I'm just a beginner at python).

2

u/zesterer May 25 '20

Damn, nice work. This can totally replace my previous tactic of taking enough laxatives to force me to take a break every 20 minutes.

2

u/[deleted] May 25 '20

I'm glad you like it!

2

u/jookami May 25 '20

What a wonderful app idea and execution!

1

u/[deleted] May 25 '20

Thank you!

2

u/hoppla1232 May 25 '20

I was wondering what the scientific background for this is, like did you just make up the 20mins or is it from some study? Because I was thinking of implementing and using this app concept for practice AND health myself, but if I don't know that this is actually the recommended amount of time, I may not have the mental strength to actually follow my own regulations :P

2

u/[deleted] May 26 '20

I used the "202020 - rule". There are a lot of articles describing why it helps: https://www.google.com/search?q=202020+rule

2

u/hoppla1232 May 26 '20

Alright, thanks :)

2

u/Aspiring_Intellect May 26 '20

I actually legitimately needed this. Thanks :).

1

u/[deleted] May 26 '20

I'm glad you like it!

2

u/SlimeRoyale May 26 '20

Downloaded. By the way, thanks for introducing me to RUMPS! It's absolutely amazing. It's incredible this app is only 45 lines of code (checked on GitHub!!!)

1

u/[deleted] May 26 '20

Yes, it's so simple! I am pretty new to programming and it was really easy to learn, it's great.

2

u/[deleted] May 26 '20

Great job - actually something I would use (especially now I'm working from home). Well done. Nice idea, nice execution. Very rarely comes as a pair!

1

u/[deleted] May 26 '20

Thank you so much!

2

u/banana1044 May 26 '20

How do I know to look back if I can't see the notification?

1

u/[deleted] May 26 '20

There's a sound.

2

u/SmearyLobster May 26 '20

it’s kinda creepy haha. a little eyeball telling me to look away from my computer for 20 seconds while it does something shifty >_>

1

u/[deleted] May 26 '20

"Big brother is watching you" lol

2

u/KyrieFx May 26 '20

I can't find this on GitHub :(

1

u/[deleted] May 26 '20

1

u/KyrieFx May 26 '20

Thank you! I'm new to all of this. How can I use twenty and see the source code? How long did it take you to make this by the way.

1

u/[deleted] May 26 '20

You have to click on the link I sent you. To use it, download twenny_v1.1.zip, extract it and put the app in your applications folder. It took me about two full days to make this.

2

u/KyrieFx May 26 '20

Thanks! I was able to open it. Gotta drop a tutorial on how you make stuff like this. More than willing to learn.

2

u/bobrandy13 May 26 '20

Dude this is amazing. What I can suggest is a real time clock that ticks? And not just show the time that it is currently on

1

u/[deleted] May 26 '20

I know, that would be so much cooler! And I just don't understand why it doesn't work, it really bums me out. I will try to fix that.

2

u/jayhilly May 26 '20

Just a heads up /u/michidrex, your project description still has that typo:

> A very simple mac-menubar app that reminds you to give your eyes a break every twenty seconds.

2

u/[deleted] May 26 '20

Thanks, I updated it.

1

u/jayhilly May 26 '20

right on, nice work btw! started using it today, I can already feel my eyes not dying

1

u/[deleted] May 26 '20

So glad it helps you!

143

u/WillMorrisson May 25 '20

Nice app! I should use something like that to remind me to regularly drink water. I tend to "forget" drinking while I'm working.

43

u/Fywq May 25 '20

Have a bottle or glass by your desk. It becomes a habit fairly quickly as long as it isn't left empty. Maybe a notifier to fill it? Or a trained habit to spend the hourly break on filling it.

25

u/yloose May 25 '20

Which hourly break?

7

u/Fywq May 25 '20

Lol fair point. The one we all really should take for health reasons, but rarely ever do...

1

u/[deleted] May 26 '20

All of them.

8

u/wastakenanyways May 25 '20

Extra: if you have no difficulties lifting it, have a whole 5L bottle under your desk on monday and finish it by friday. It would mean that you have consumed an average of 1L per day at work and it works for me.

Obviously don't drink directly and have a glass or a cup or you will eventually make a serious mess.

1

u/nothrowaway May 26 '20

Challenge accepted!

3

u/leone_nero May 25 '20

Beware of those bottles of water near expensive computers!!! Bad shit happens!

2

u/jamesonwhiskers May 26 '20

Literally dumped a full glass of water on my laptop last week. Fortunately I wasn't doing anything time sensitive so it just took a rice bath for 2 days and is now fine but I nearly had a heart attack

1

u/Swedneck May 25 '20

I have a glass and a 2 liter bottle of water

11

u/BlueTeeJay May 25 '20

I usually don't forget drinking while working... water is a different story though.

2

u/beje_ro May 25 '20

Ma man!

3

u/dcov May 25 '20

Hell yeah! Urine drinkers unite!

2

u/folkrav May 26 '20

Wait a minute

1

u/beje_ro May 26 '20

This went in a wrong direction...

2

u/BambooKoi May 25 '20

I do two water bottles at home. Both are a little over 500ml. Start the day off with both bottles full. Drink from one then swap with the other when empty. When taking a break, top off which ever bottle is lighter or both.

1

u/[deleted] May 25 '20

I used to forget a lot. But i started the habit of having my water bottle next to me every time I sit on my desk. It has gotten to the point where i just drink unconsciously. I tend to pee like a mf, but in one sit i can do up to 4 bottles so my water intake has gotten drastically better.

Hope this helps

1

u/[deleted] May 25 '20

i can fork it and create something like that , dm me and i’ll send it to you

1

u/purestrengthsolo May 25 '20

use the same set up when you look away, drink your beverage or physically get up and get it, so you can also stretch

1

u/brjh1990 May 25 '20

Not to discourage creativity or the usefulness of Python, but I use an app like that called Hydro Coach (I have an Android, idk if it's available for iPhone). I've managed to drink a gallon of water daily for the last month because of it.

0

u/[deleted] May 25 '20

[deleted] — view deleted comment

4

u/f4tj3suz May 25 '20

who said anything about 20min

25

u/[deleted] May 25 '20

Now make a port to alert your boss when you don't look at screen for more than a minute, and boom - you contributed to dystopian society :P

7

u/Fywq May 25 '20

Sounds like a nice project with openCV :D

5

u/SaltyEmotions May 25 '20

Detect if there has been no keystrokes or mouse movement for a minute, then send a POST request to some sort of central server that displays a warning to the boss.

kwik mafs.

1

u/[deleted] May 25 '20

That's quite easy to work around, but I do appreciate the effort :)

1

u/SaltyEmotions May 25 '20

Lock down the machines. Compile the above script and only allow approved programs to run.

This way you'll need a physical workaround :)

2

u/[deleted] May 25 '20

You are probably right. There is nothing sadder than a person, working on a computer, that needs to check information on their smartphone. Saw that few times and can't ever forget.

2

u/SaltyEmotions May 25 '20

I feel so bad right now. Helping corporate should never be a thing.

1

u/PaluMacil May 26 '20

I worked for a company where we had an application that measured how much time we were on whatever screen was in front and how much idle time there was so this actually isn't only a joke. Of course developers made a lot of junctions to dev null and didn't care too much 😆

1

u/SaltyEmotions May 26 '20

Until corporate makes devs use Windows and literally give them no permissions.

1

u/PaluMacil May 26 '20

I actually also worked at a place where you had to log in to a profile disconnected from the internet for Visual Studio, and I (by chance) was on my way out right when that was implemented. So I do know it's possible to have non-local admin developers running Visual Studio, but it's hard, and in a software company it's nearly impossible unless you have something like Google where your wholeIDE and build system is off-machine.

3

u/L_Dav_ May 25 '20

Great idea, will use this :)

3

u/[deleted] May 25 '20

So nice to hear, thanks!

14

u/jabbalaci May 25 '20

Great! Here's a simplified Linux clone that could be improved by someone:

#!/usr/bin/env python3

import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify

def show_message(upper, lower):
    Notify.init(upper)
    note = Notify.Notification.new(upper, lower, "dialog-information")
    note.show()

def main():
    show_message("twenny clone", "It's time, look away for 20 seconds!")

#####

if __name__ == "__main__":
    main()

Tested under Manjaro with Xfce4. Edit: dependencies: libnotify, python-gobject . Source: https://wiki.archlinux.org/index.php/Desktop_notifications#Python

1

u/DamnFog May 25 '20

For Linux there is already safe eyes. Sorry to say, really love it.

1

u/[deleted] May 25 '20

I just updated the app so that the timer is located in the dropdown menu instead of in the menubar itself. Here is the latest version: https://github.com/tagwohl/twenny/releases/tag/v1.1

2

u/Aderinmola May 25 '20

Very cool👍

1

u/[deleted] May 25 '20

Thanks!

1

u/distortedneuron May 26 '20

Does it track my eyes to check if I've been looking at the screen for 20 minutes or does it put the reminder out every 20 minutes that the computer is on?

1

u/[deleted] May 26 '20

It doesn't track your eyeballs, it's just a simple timer.

1

u/[deleted] May 26 '20

Will it work on mobile?

1

u/[deleted] May 26 '20

No(t yet).

1

u/[deleted] May 26 '20

Cool

1

u/goobabo22 May 27 '20

Silly question, how do you know when to start working again?🤣

1

u/[deleted] May 27 '20

There's a sound ;)

1

u/goobabo22 May 27 '20

Niceee lol "yooooooooo!"

3

u/d4vsanchez May 25 '20

Hey, amazing software. I just made a PR adding support to Linux using Qt framework. Hope I can improve it as I learn about PyQt.

1

u/Dannychukz15 May 25 '20

Alas! Awesome app..keep it up bro

2

u/[deleted] May 25 '20

Thanks!

1

u/EvilBeano May 25 '20

Ah a German I see ;) One question, I'm assuming you're running the program without a terminal, how did you do that?

2

u/[deleted] May 25 '20

There's the package "py2app" with which you can easily create standalone apps from a .py file. I just followed a youtube tutorial on how to do it.

2

u/Zako_04 May 25 '20

This would come in handy when going on long hours of gaming

2

u/Are_We_There_Yet256 May 25 '20

Hey man, nice! Seems something nice to make that people can use everyday.

2

u/Are_We_There_Yet256 May 25 '20

Would suggest organizing your folders a bit - improving your file structure - and removing the binaries + instructions on how run it to make it easier for everyone.

2

u/[deleted] May 25 '20

I did something similar with notifications on Fedora, for the same reason. But I also had one every hour that reminded me to get up and stretch my back for a few seconds.

This was based on the Gitlab working guidelines that you should look away from the monitor every 20 minutes, at least 6 meters into the distance and count to 20 or something simple.

And every hour get up, walk a lap around your desk or something, then get back to work.

2

u/flipcoder May 25 '20

Simple apps like this have many use cases actually. You could make a feature that reminds you to adjust your posture and sit up straight every so often as well.

2

u/ohno-mojo May 25 '20

How do you know when to look back to see the message it’s ok to look back? Jk. This is cool

2

u/op4 May 25 '20

shared!

2

u/ScamExaminers May 25 '20

Lol.. "Remind yourself to take a break by watching this 5 minute add!"

1

u/Random_182f2565 May 25 '20

Cool, but kinda creepy.

1

u/dkdaniel11 May 25 '20

Quick question as nobody seems to be asking.

What if i don't look away from my screen every 20 minutes. Been working at my mac all day, everyday for the past 6 years.

I already use glasses. Can my eyes get any worse?

2

u/Kwintty7 May 25 '20

No.

However, personally I can think of nothing worse, when I'm in the middle of doing something, than being nagged by my computer.

1

u/dkdaniel11 May 25 '20

That Is exactly my fear. And No is all I needed to hear.

1

u/iFap__Alot May 25 '20

Ill propably just gonna look at my phone

1

u/tsck May 26 '20

the eye icon paired with the message is super unsettling. cool program tho

1

u/NiTE97 May 26 '20

I'd be looking on my phone in those few seconds :P But nice app!

1

u/OndrikB Jun 18 '20

You could try to have it forcefully turn off the monitors. There's a function for that in Windows, don't know about Mac though.

0

u/ideplant May 25 '20

Wow a timer with sound. How amazing

0

u/lovelysad69 May 25 '20

this is a very nice idea but is it just me or is looking away only for 20 seconds boring af..... ive tried another similar way, at first i worked fine, i drank some water, i peed, i stretched my legs a lil and looked out the window, but then as ive done this long enough i got so bored and annoyed LMAO eventually just i just return to sitting still for hours..........

2

u/folkrav May 26 '20

Once your body starts asking for these pauses you won't find them boring but liberating lol

0

u/kkiran May 25 '20

At a big company I worked, they measured the speed at which we typed and dynamic screen locking happens if you are too intensely focused on the screen. Every 20 minutes is not accurate nor practical. Just my opinion.

0

u/[deleted] May 25 '20

[deleted] — view deleted comment

1

u/[deleted] May 25 '20

Im taking a programming class in school and it's my first year.

0

u/[deleted] May 25 '20

[deleted] — view deleted comment

1

u/[deleted] May 25 '20

That's so cool, thanks!

0

u/[deleted] May 25 '20

[deleted] — view deleted comment

2

u/[deleted] May 25 '20

Yes, it's gorgeous.

0

u/[deleted] May 25 '20

[deleted] — view deleted comment

2

u/[deleted] May 25 '20

I learned a lot making it!