SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 Tips, Tricks & Scripts » Simple bash script to put time limit on internet usage » 2011-11-11 21:35:26

mxlmpr
Replies: 2

This is surfsup, my first bash script of any potential use. Whenever I start Firefox, it asks me how long I want to surf, starts the browser and kills it after the specified timespan. The point is to become aware of the time you spend on the internet.

#!/bin/bash

#  Surf's Up
#  Surfsup asks you how long you'd like to surf the internet.
#+ It then shuts down the browser after the specified timespan.

browser="firefox" # Insert your browser of choice here.

surfsup=`zenity --entry --title="Surf's Up" --name="surfsup" --text="Your time is precious. How many minutes do you want to surf? " --entry-text="0" --timeout="10"`

if [ "$surfsup" = "" ]; then
    exit
fi
if [ "$surfsup" -eq "0" ]; then
    exit
fi

$browser &

let "surfsup *= 60"

sleep $surfsup && zenity --notification --text="SURF'S UP\!" --timeout="4"

killall $browser

let "surfsup /= 60"

zenity --warning --title="Surf's Up" --text="$surfsup minutes are over... your SURF'S UP\!" --timeout="4"

exit

To make it happen, you have to manipulate the way you habitually start your browser. Put surfsup in the ~/bin directory and its filename instead of "firefox" (or whatever browser you use) in the menu.xml file. Or change the keybinding from firefox to surfsup in rc.xml. In any case it'll be easy to override, but your habit will work in your favor.

Yes, I can think of ways to make it less clumsy and more functional, but I stopped working on it as soon as I got it running. Maybe you folks...

I share my thoughts and feelings about it in this post: http://crunchbanglinux.org/forums/topic … ll-script/

#2 Re: Feedback & Suggestions » Noob writes first shell script » 2011-11-10 11:40:25

Wow, thanks for your feedback. I'll gladly post the script in the scripts subforum (tomorrow), as rhowaldt suggested. And I'll tell you about my motivation for writing it right here.

I translate for a living. I like doing it, but I am easily distracted and prone to getting lost in the web. Since I do not believe in self-discipline, I divided the work into writing and editing, with the first part to be done offline (I have the router cut off my connection the whole evening). Which works fine. But when I'm editing and looking things up, I'll wander off. That's how I got the idea of setting a time limit on browser use.

At the moment, I'm not interested in refining the script, but in finding out how it affects my behavior. The first thing I noticed was that I always underestimate the time I actually need/use to get things done.

Do you guys employ any self-restricting hacks?

#3 Feedback & Suggestions » Noob writes first shell script » 2011-11-09 11:13:47

mxlmpr
Replies: 10

I wrote my first shell script the other day. Whenever I start Firefox, it asks me how long I want to surf, starts the browser and kills it after the specified timespan. (I'm into productivity hacks.) Nothing special, but I feel very proud about it.

I guess that this could've been done on any other OS, even on Windows. But as a regular GUI guy, I would never have gotten the idea. About a year ago, I chose Crunchbang for its speed and looks, but underneath the sleekness I found it to be pretty DIYish. It forced me to edit config files and to solve things geek-style. I'm just beginning to learn what "infinitely hackable" means. Hell, I could do ANYTHING with this (if I was smart enough)!

Thanks, Crunchbang. This is fun.

#4 Introductions » Saved long outdated but beloved hardware with CrunchBang! » 2010-05-25 20:05:37

mxlmpr
Replies: 11

My 10 years old, XP-stricken ThinkPad was a real pain to work with, but then #! came along and turned it into something useful, quick and pretty to look at. Now what else would I run on my new ebay-bought desktop? Thanks a lot!

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo