Category Archives: linux

Scheduling notifications on Ubuntu in a geeky way

Several days ago I tried to find out a way to schedule notifications on my Ubuntu, mostly for myself. The reason why I bothered about it is because I wanted to get rid of all the distractions namely email notifications, messenger, etc. so that I can verify updates – e.g. new emails without breaking concentration and actually staying in the Flow.

Luckily I’m using Ubuntu as an OS for my work. And this wonderful OS has everything what we need to set up notifications without the need to install extra software, if you geeky enough :)

In order to show notification on Ubuntu you may use wide variety of the existing command line tools, e.g. zenity, notify-send, etc. I picked notify-send as it generates nice auto-dismissable popup notifications, e.g.

notify-send "Check Email: `date`"

For scheduling I used cron.

But the straightforward way of using X-windows-bound things like notify-send won’t work being used by cron directly. This is because cron tasks are executed from the special, cron user. But if this user have sufficient priveleges to read your .Xauthority it is not a problem (and usually it does, and it does on Ubuntu if not specially reconfigured).

So I ended up with the special notification launcher, like this one:

# !/bin/bash

export DISPLAY=:0.0;

# $HOME/.Xauthority
export XAUTHORITY=/home/alex/.Xauthority

/usr/bin/notify-send "Check Email `date`"

I saved this script under the name /home/alex/notify_email

Then I added cron task that was able to launch my script. You may manage your cron tasks by using crontab utility, e.g. list existing task – sudo crontab -l and edit cron task by invoking sudo crontab -e.

My configuration looked as follows:

# m h  dom mon dow   command

40 * * * 1,2,3,4,5  /home/alex/notify_email

This means – invoke notify_email script once per hour, in each *:40 minutes, each working day (remember – the week starts with Sunday that comes under the number 0).

That’s it. Have fun!

Adding custom Intellij Idea launcher on unity (Ubuntu 12.04)

As you know Intellij Idea comes in tar.gz distribution for linux OS, so it is only possible to launch it from terminal after unpacking.

But there is a possibility to add quick launcher button for unity.
First of all, create idea.desktop file with the following contents:

[Desktop Entry]
Name=Idea Community Edition
Comment=Launch Idea Community Edition

Paste your location to the Idea distribution in the italicized text given above.
After that, open this file in nautilus and just drag it to your launcher bar.

Ubuntu: add user from the shell

The following script does the trick:

sudo su - // elevate priveleges to the superuser
useradd -d /home/USERNAME USERNAME // create user with home dir
passwd USERNAME // set password for the user
chown USERNAME /home/USERNAME // grant priveleges for using the home dir
chsh -s /bin/bash // specify to use bash when the user logs in

Words in uppercase implies user-specified values, e.g. instead of USERNAME type the login name of the user you wish to add.