For a very long time I’ve used a script that either raises a running application or, if the application has not been launched yet, launches a new instance of the application. I use that script for some of my most used applications–like Thunar–and it has helped me enormously to keep my desktop tidy.

Tonight I decided it would be great to be able to do that with any application. Wouldn’t it be nifty if I could use this script in combination with dmenu?

It would indeed. Here is the result:

#!/bin/sh

CMD=$(dmenu_path | dmenu -b -fn '-*-nu-*-*-*-*-*-*-*-*-*-*-*-*' -nb '#545043' -nf '#D2C7A7' -sb '#D2C7A7' -sf '#545043')

# if no instance of the app has been started, launch one now
if [ -z "`wmctrl -lx | grep -i $CMD`" ]; then
$CMD &
else
# search for existing app on any desktop and move it to the current desktop
app_on_any_desk=`wmctrl -lx | grep -i $CMD | cut -d ' ' -f 1`
wmctrl -i -R $app_on_any_desk
fi;

If no instance of the application you launched with dmenu is found this script will launch a new one. If there is an instance running, it will move it to the current desktop and focus it. If you prefer to move to the desktop where the application is currently running instead, change the last wmctrl command to wmctrl -i -a $app_on_any_desk.

You’ll need to make the script executable (chmod +x path_to_script) and you’ll need both wmctrl and dmenu installed. Dmenu is part of the suckless-tools package on Debian Testing and recent Ubuntu versions.

The colours dmenu uses in this script are the Erthe colours. Change them to your liking if you don’t like brown.

You can find this script (and a few others) also on my new github repository.

bbdock on Debian Wheezy

July 21, 2012

If you’ve tried to compile the source code for bbdock, that nifty little blackbox dock, on Debian Wheezy (and presumably other recent distros) without much success, try Markus Fisch’s bbdock code on github. If you have the proper dependencies installed (libx11-dev and libpng-dev on Debian) it should compile with the usual ./configure, make, and make install.

About a year ago I retired most of my computers, and am now left with only two: Loka, my old desktop (now with a new 23″ screen), and Savitar, a Thinkpad X41 I bought about 18 months ago.

Both computers run Debian Testing. My main desktop environments and window managers on Loka have been Xfce with Openbox and WindowMaker, which I rediscovered this year. On Savitar, I used only Openbox and Awesome.

Loka

Xfce 4.6 with Openbox, using the Alghattas Openbox and Gtk theme, and the Elementary icons. I don’t remember where I found the wallpaper.

Xfce 4.6 with Openbox, using the Alghattas Openbox and Gtk theme, the Elementary icons, and this wallpaper.

Xfce 4.8 with Openbox, using the Erthe Openbox and Gtk theme, the AnyColorYouLike icons, and part of this image as wallpaper.

Xfce 4.8 with Openbox, using the Erthe Openbox and Gtk theme, and the AnyColorYouLike icons.

WindowMaker, with the ShikiBlack WindowMaker theme, the Shiki-JetBlack Gtk theme, and the Moblin icons. I don’t remember where I found the wallpaper.

Savitar

Awesome, with the Children of the Earth Awesome theme, Gtk theme, and icons, and Caspar David Friedrich’s Monk am See.

Openbox with the Children of the Earth Openbox theme.

I had written this a year ago, but somehow forgot to post it. But here are my screenshots from two years ago.

As I’ve been doing for a few years now, I am posting screenshots of my desktops of the past year, to amuse you (nearly everyone likes to look at screenshots), to document my changing aesthetics, and to capture my mood of the year as reflected in these images.

Below are the screenshots of the computers I’ve used in the past year. Aryaman is a Thinkpad 240 I bought on ebay for £10. I used it particularly when travelling, or when working in a library. I no longer use Mitra (my 11 year old Dell Inspiron 2500) and Yantra (my 10 year old Compaq Presario), but recently gave them away to others who found some good use for them. Loka is my old desktop.

Aryaman


Musca 0.9.24

Loka

Openbox 3.4.10 in Xfce 4.6, with the Fearless Openbox theme, the Umbra Gtk theme, and the Iris icon theme.

Pekwm 0.1.11, with the Elegance Pekwm and Gtk theme, and the Iris icon theme.

Pekwm 0.1.12, with an updated Groove Pekwm and Gtk theme, and the nuoveXT-1.7 icon theme.

Pekwm 0.1.12, with the Groove Pekwm and Gtk theme. The icons are from the Any Colour You Like icon theme.

Pekwm 0.1.12, with the Groove Pekwm and Gtk theme. The wallpaper is home made.

Openbox 3.4.10, with the Brume Openbox and Gtk theme.

Xelatex and Gedit

February 7, 2011

For all my Tex needs, I use Gedit with the excellent Latex plugin. For a while I used Texworks. I particularly liked its “Jump to pdf” and “Jump to source” feature (which I wish more Latex editors would implement), but in the end, its sparse customisability or lack of extensibility and its fairly basic default features led me back to Gedit (after a brief stop at Gummi, a young, but promising Latex editor).

The Gedit Latex plugin uses rubber to build the pdf of your text file. I write my documents in Xelatex, however, and not in Latex, because I need Unicode fonts (for Devanagari and diacritics). As it turns out, it is really easy to use rubber with Xelatex. Simply add the following line to your .tex file:

% rubber: set program xelatex

When I’m working on my computer, I often lose track of time. In itself I don’t mind this, but the downside is that I often am not aware of the different sandhyas, the different phases of the day (sunrise, noon and sunset) at which I should meditate on the Gayatri mantras I received at initiation.

Luckily, with Linux it is very easy to have your computer remind you that it is nearly time to chant. All you need is crontab and gxmessage. Crontab is part of the default installation of many distributions, and gxmessage is easily installed (. Here is how you would do it.

First of all, you’ll need to create a Gxmessage script. Here is what I use:

#!/bin/sh

gmessage "It is time to chant your Gayatri mantras" -center -title "Take action" -font "Sans bold 7" -geometry 300x100 -default "Remind me later" -center -buttons "_Remind me later":1,"I'll _chant now":2 >/dev/null

case $? in
1)
(sleep 10m && /home/USERNAME/.scripts/Gayatri_gmessage);;

2)
echo "Exit";;

esac

Save the file in a convenient location as (I keep it in ~/.scripts/) as Gayatri_reminder or whatever else you like, and make the file executable with the following command:

chmod +x /home/USERNAME/.scripts/Gayatri_reminder

(Wherever you save it, make sure that the line which reads “sleep 10m && /home/USERNAME/.scripts/Gayatri_gmessage” in the above example points to the location of your script.)

If you’d like to test the script, you should be able to either double click on the file, or to enter the full path to the file in a terminal to launch Gxmessage. The script should launch a window that looks like this (it should follow your general Gtk theme):

If you click “Remind me later” the window will pop up again 10 minutes later; if you click “I’ll chant now” the message will simply close. You can change those settings (including the text that is displayed) by editing the script I gave above.

Now you’ll need to tell your operating system that you want this script to be run every day at noon and at 6pm. To accomplish this, you can use cron and crontab. Cron is a daemon that executes scheduled commands. It is normally started automatically when you start your computer. Crontab is a little application that allows you to add or remove scheduled commands for individual users. To add an entry for your Gayatri reminder message, start crontab in the edit mode with the following command:

crontab -e

If you have never used crontab before, an empty file should open that looks like this:

# m h dom mon dow command

This indicates the structure you need to use for crontab entries: for each entry you can specify the minute (0-59), the hour (0-23, 0 = midnight), the day of the month (1-31),the month (1-12), and the day of the week (0-6, 0 = Sunday), and finally the command you want to be executed at that time. If you want to run a command every day of the month, or every day of the week, you can enter an asterisk (*) as the value to that setting.If you want to cron to launch an application with a graphical user interface, such as Gxmessage, you need to specify what screen to display it on with the command export DISPLAY=:0. If you only have a single screen, you need to use DISPLAY=:0; if you have more than one screen and would like the message to appear not on the first screen change the number accordingly (to :1 or :2).

So if you want this Gxmessage script to be run every day at noon,and at 6pm, you would add two entries in crontab that looks like this:

00 12 * * * export DISPLAY=:0 && /home/USERNAME/.scripts/Gayatri_reminder
00 18 * * * export DISPLAY=:0 && /home/USERNAME/.scripts/Gayatri_reminder

This will run the script every day of every month and every day of the week (the three *s) at 00 minutes past 12 and 18 hours. The command part of each line ( export DISPLAY=:0 && /home/USERNAME/.scripts/Gayatri_gmessage) specifies that the Gayatri_reminder script is to be run on the first screen.

There are some obvious drawbacks to this system. If you want to be very strict and meditate on the Gayatri mantras at the exact sandhya times, this method is not very practical, unless you live close to the equator where the sunrise, sunset and when the sun reaches its zenith are nearly at the same time of day all year round. I started writing a script that took the exact sunset times into consideration, and had some success, but lost that script and can’t be bothered to rewrite it. Maybe I’ll revisit it in the future, but for now this system works fine. I’d rather chant my Gayatri mantras slightly off time, than forget them entirely.

A simple timer

June 16, 2010

This post is really meant for me, to remind me later how to do this, but perhaps you’ll find something useful in it too.

This is a little script using zenity that functions as a timer . When I run the script I am asked to enter a task description and then in how many minutes I want to be reminded of that (“10″ is ten seconds, “10m” is ten minutes). When the time is up, a simple dialog appears that reminds me to do the task I set myself.

#!/bin/bash
#
REMINDER=`zenity --entry --title="Timer" \
 --text="What should I do?"`
WAIT=`zenity --entry --title="Timer" \
 --text="When should I do this?"`
sleep $WAIT
zenity --info --title="Timer" --text="$REMINDER"

Now I no longer need to launch a panel to run a timer panel applet (which I am sorry to admit I did for a while). This is simple and works great.

And here, with some delay, is my review of 2009.

As I mentioned a year ago my desktops generally reflect my mood. I chose a particular wallpaper and a matching theme or colour scheme that speaks to me at the time. The pictures that follow thus capture 2009, as I lived it.

Last year I did not change my desktop that much. I found a few themes I really liked (Umbra, Children of the Earth, Eidolon and Salvage on the four computers I’ve used last year) and stuck with them or repeatedly revisited them.

I’ve mainly used Openbox last year, but when I discovered Musca, that became the default window manager on Mitra (and the only screenshot you see of that was my desktop for a very long time).

Yantra and Mitra are laptops (an 8 year old Compaq and a 9 year old Dell respectively). Loka is a desktop of a similar age, while Grantha is my office computer. Yantra was my main computer up until October, when I began to use Loka more (after neglecting it for a few years). The screenshots are grouped per computer and ordered chronologically (oldest first), as good as I could remember.

All the screenshots of Mitra and Loka below are of Debian Testing (first Lenny, then Squeeze), with the exception of the first Loka screenshot which is still of an Ubuntu 6.06 (Dapper) install. Yantra and Grantha run Ubuntu 8.04 (Hardy).

Read the rest of this entry »

Elinks is a great browser, but rather limited when it comes to websites that use more than just text. Youtube, or other websites that host flash videos, are fairly useless in Elinks, as you can’t access that what they are all about (and, let’s admit, no one really wants to read the comments on Youtube…)

It is, however, possible to use Elinks in combination with other applications to access and view the flash videos on Youtube and other such sites. I will describe two ways here, one using youtube-dl (wholly following finferlu’s explanations) and the other clive (or cclive if you prefer that). Both methods use mplayer to play the video, though you could adapt both to use any other media player that plays flash videos if you so prefer.

Youtube-dl

First download and install youtube-dl, which is available in the repositories of most distros. If you use Debian Testing, download the package from the sid repostories and install that (dpkg -i youtube-dl_2009.09.13-2_all.deb), as for some reason it has not made its way to the Testing repos.

Once youtube-dl is installed, create the following script:

#!/bin/bash

video_url=`youtube-dl -g $1`
mplayer -vc ffflv -ac mp3 -cache 300 -prefer-ipv4 $video_url > /dev/null 2>&1

Save the script somewhere in one of your executable paths (I have it in /usr/local/bin as utube), and make it executable (chmod +x filename).

Now start elinks, and go to the “Options manager” by pressing o or through the menu (press Escape) in Setup > Options manager. Select the category “Document” and press + to show all the options. At the very end of the the list (just before the next section, ECMAScript) there is an subsection called “URI passing”. Navigate to that section and press a to add an entry, and give it an appropriate name (I called mine youtube). Select the newly created entry and press e to edit it. You should see the following window:

Add the command utube %c (replace utube with whatever you called the above script) into the “Value” field as in the above picture, press Enter, and press v to save the new settings.

Now you need to assign a keybinding to this script, so that you can tell Elinks to launch it when you want to view a Youtube video. Close the Options manager if you haven’t done so already (press c) and open the “Keybindings manager” (press k or go to “Setup > Keybindings manager” in the menu). Open the first section called “Main mapping” with the + key.

You now have two options (or three if you decide to use both). You can assign a keybinding to tell Elinks to view the Youtube video of either the selected link, or of the current page. With the former, you don’t actually have to browse to the page of the Youtube video you want to view, but can just select the link to that page from your Youtube search results list. With the latter you’d have to be on the page that contains the video.

To assign a keybinding to play the video of the selected link, select the “Pass URI of current link to external command” and press a to add a keybinding, and enter the keybinding you want to use in the “Keystroke” field.

To play the video of the current page, select the “Pass URI of current tab to external command” and add your keybinding there. Inverting finferlu’s choice, I use “Alt-p” for the current link, and “Alt-o” for the current page or tab.

Once all the above is done, you’re all set to watch Youtube videos with Elinks and Mplayer. Simply press “Alt-o” to view the video of the current page, or “Alt-p” to view the video that is linked to by the selected link, and Mplayer should stream the video nearly instantly.

Clive

Using youtube-dl to watch Youtube videos has a few disadvantages. First of all, it is limited to Youtube (though you could modify the above with metacafe-dl or nicovideo-dl to watch videos from metacafe.com and the to me entirely unknown nicoveo.jp). Secondly, though mplayer streams the videos very fast (much faster than the flash player in a graphical browser on my old computers!), it is hard to jump ahead with this method, as the mplayer first stutters and then freezes whenever I attempt that.

Using clive instead of youtube-dl handles both of these better. According to the website, clive supports the following websites (most of which I had never heard of): Youtube, Google, Sevenload, Break, Liveleak, Evisor TV, Dailymotion, CCTV (not to be confused with “closed-circuit television”), Redtube, Vimeo, Spiegel.de, Golem, ehrensenf.de, Clipfish, Funyhub, adn Myubo. Secondly, fast forwarding with clive works really well (as long as it has streamed that far ahead), and results in smoother playback. Clive does have some disadvantages. It will download the video file to your harddisk, and it takes a little longer before Mplayer starts playing the video.

The method to use clive instead is largely similar to that of youtube-dl. Open the Options manager in Elinks, go to the “URI passing” subsection of the “Document” section and create a new entry: press a and name the new entry “clive”. Select the new entry, press e to edit it, and add the following command in the “Value” field:

clive -q --save-dir=/tmp --stream-exec=\"mplayer -really-quiet %i\" --stream=10 %c

If you would prefer to let clive stream more before mplayer starts to play, increase the value after the “–stream” option (in percentage). If you want to view the best quality of the video available add “–format=best” to the above command (before “%c”!). For more options, see man clive.

If you have used both the clive and youtube-dl methods (or if you have created some other URI passing options), you will be presented with a list of commands that appears at the position of your cursor when you press Alt-o or Alt-p. Select the one you prefer, and press enter. If you only have one “URI passing” command, that one will automatically load when you press your keybinding.

And so you can watch your favourite Youtube (or Google Video, or Vimeo, or …) clips without having to rely on Flash, or even X. Now K.Mandla can finally watch his favourite slug races on the framebuffer! :twisted:

One of the little things I do not like about Debian (and there are not that many of them!) is that  the Iceweasel icons are…uhm…strange. Look at it:

iceweasel3

The weasel’s body has a really odd, wide and flat shape (look at his hind leg!) and the poor creature looks exhausted and  sad. But when you consider what the Iceweasel folks want to suggest with the picture (access http: //www.geticeweasel.org/ with Iceweasel and you’ll see) the picture is not just odd but rather disturbing.

That Iceweasel has such a terrible icon is sad, especially since there have been so many good alternatives available from the very beginning. The Ubuntu Wiki contains a whole page of different icons that are terrific. My favourite is without a doubt this one:

iceweasel-icon_lostinbrittany_04_117x117

It is easy to change the icon of Iceweasel’s launcher or menu item (if you use one), but how do change the icon that appears in the taskbar or the alt-tab dialog? It isn’t much harder, really.

Iceweasel stores its icons in /usr/share/iceweasel/chrome/icons/default and /usr/share/iceweasel/icons. Replace those icons with the icons of your choice. Make sure your new  icons have the same shape/size, name, and filetype — you can change all that with Gimp if necessary. Restart Iceweasel, and you’ll notice the icons have changed.

The Iceweasel icons stored in /usr/share/pixmaps and /usr/lib/iceweasel/ are linked to /usr/share/iceweasel/chrome/icons/default/ so they will be changed automatically when you change those icons.

Follow

Get every new post delivered to your Inbox.

Join 67 other followers