Ubuntu: How can I create a shortcut that acts as a tally



Question:

For my work I have to do repetitive tasks with weekly deadlines. I like to know how close I am to finishing these tasks so I tend to keep a tally on a piece of paper. Unfortunately I travel a lot and don't always have a pen or a notebook. This is fine because I just gedit as an alternative, but sometimes I forget to save gedit when I shutdown and lose track of my tally.

What I really want though is a way of setting a shortcut so that each time I complete a task it is logged somewhere and saved instantly. It also needs to be quickly and easily displayed somehow.


Solution:1

Maybe you can use emacs with org-mode. It's much more powerful than just simple manage your tasks, but might be worth to dig into.


Solution:2

The simplest way of solving that I found was to create a dash script that stores the tally in a text file and displays the value using notify-send.

I used source to set the location for the values I wanted to keep a tally of:

#!/bin/sh  . /home/jesse/.scripts/tally  

And the tally file just has a single line which reads:

written=0  

Then I created functions for showing the tally, clearing the tally and adding to the tally.

To show the tally I needed to start by reloading the tally to make sure it is up to date. Then I can use notify-send like this:

show() {    . /home/jesse/.scripts/tally    notify-send -i "/home/jesse/.scripts/icon.png" \    "Total for this week:" "Written: $written"  }  

To add to the tally the function needs to read from the tally, add 1 to the value, rewrite the tally and then call the show function:

add() {    num=$(($written + 1))    printf "written=$num" > /home/jesse/.scripts/tally    show  }  

The clear function is fairly self-explanatory:

clear() {    printf "written=0" > /home/jesse/.scripts/tally    show  }  

Finally, in order to call the individual functions from the script I needed to finish the script with $@ so that the arguments can be called verbatim. The complete script is:

#!/bin/sh  . /home/jesse/.scripts/tally  show() {    . /home/jesse/.scripts/tally    notify-send -i "/home/jesse/.scripts/icon.png" \    "Total for this week:" "Written: $written"  }  add() {    num=$(($written + 1))    printf "written=$num" > /home/jesse/.scripts/tally    show  }  clear() {    printf "written=0" > /home/jesse/.scripts/tally    show  }  $@  

From there I could assign keyboard shortcuts to call individual functions from the script and manage a good looking tally that is displayed in the notification window just by pressing a couple of buttons.

Hope this helps somebody. This is my first dash script and I'm happy with it, but there's bound to be cleaner ways of achieving this.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »