1

I am not sure if is my question clear enough so here is some explanation what I am trying to achieve.

I need to create custom shortcut to run hamster (time tracker) to track new activity. The command is:

$ hamster start <activity name>

so I want to press the hotkey ( Super+H ) and then want to be prompted for activity name. Then the text I will enter will be used in the command

$ hamster start <my entered text>

Thanks a lot.

3 Answers3

5

Would something like

hamster start "$(zenity --entry)"

work for you?

dadexix86
  • 6,776
2

If you are trying to get a script that will prompt you for the activity name you can use the following code

#!/bin/bash

echo "Please enter the activity name"
read activity

hamster start $activity

when you run the script, you will be prompted with the message "Please enter the activity name". once you type your activity name and press enter, it will run hamster start activity. you can place this script in /usr/local/bin for easy access. Basically if you name it "myscript" and place it in that folder, you can run the script just by running myscript. remember to make it an executable first.

Rumesh
  • 1,449
1

In case someone is using hamster and will find this feature handy this is my current working code:

#!/bin/bash
file=/usr/local/bin/hamster-log
last=$(<$file)
activity=$(zenity --entry --title "Enter new activity name" --text "New activity name:" --entry-text "$last")
hamster start "$activity"
if [ ! -z "$activity" ]; then
    if [ -f "$file" ]; then
        echo "$activity" > "$file"
    fi
fi

It is placed in /usr/local/bin/ folder. And in the same folder is file hamster-log with permissions 777. I am using Shortcut Super+H and to run this script and Super+Shift+H to stop the activity (command hamster stop). When I will have more time I will keep working on this and updating the code. There are few more features I would like to add.