Posts Tagged ‘gnome’

Lock and unlock the screen from command line

January 30, 2013 Leave a comment

Is there a way to lock/unlock the screen from a script?

The answer is “yes”. Lock the screen:

gnome-screensaver-command -l

Unlock the screen:

gnome-screensaver-command -d

Demo (lock the screen, then unlock it in 5 seconds):

gnome-screensaver-command -l && sleep 5 && gnome-screensaver-command -d

Tip from here.

Make room! Make room!

January 29, 2013 Leave a comment

Under Gnome/Unity, you want to increase the number of virtual workspaces.

Start CompizConfig Settings Manager (ccsm), then General -> General Options -> Desktop Size tab. Here adjust the horizontal and vertical virtual size.

The title of this post is a reference to a novel of Harry Harrison.

Categories: ubuntu Tags: , , ,

Set a local file or an image by URL as your wallpaper

April 22, 2012 Leave a comment

You browse the web and you find a nice image file. “Hey, it’d look cool on my desktop!” Or, you browse your local image files: “Hey, I want to see it as my wallpaper!” How to set a background image painlessly?

With jabbapylib, of course :) Just use my new little script:

# the image is on the web:

# the image is a local file:
set_wallpaper sunshine.png

That’s all. The script is here. It relies on jabbapylib. Tested under Ubuntu Linux.

Categories: python, ubuntu Tags: ,

Set a wallpaper from command line in Gnome 3 (Unity, Gnome Shell)

April 5, 2012 Leave a comment

Under Gnome you could set the wallpaper from command line with the following commands:

gconftool-2 --type=string --set /desktop/gnome/background/picture_filename /path/to/image.jpg
gconftool-2 --type=string --set /desktop/gnome/background/picture_options stretched    # stretch the image

You try it again on a newer Ubuntu that uses Unity, and nothing happens! What’s going on?

The new way of setting a wallpaper is this:

gsettings set org.gnome.desktop.background picture-uri file:///path/to/img.jpg

Notice that you must provide a URI, hence the “file://” prefix.

The first snippet works with Gnome 2. The second one is for Gnome 3. To figure out your Gnome version, launch the command “gnome-session --version“.

Python API
I have a general-purpose Python library called “jabbapylib” (installable with pip). Setting the wallpaper is implemented here. You should use directly the module.

This tip is from here and here. Thanks.

Making gnome-terminal usable

August 11, 2011 Leave a comment

On one of my laptops I had problems with the terminal emulators “konsole” and “terminator”. I had tried “gnome-terminal” a long time ago but I didn’t like it. Now I gave it another try and I could make it usable :)

By default, gnome-terminal starts in a little window of dimension 80×25. If you want it maximized, start like this: “gnome-terminal --maximize“.

I made a custom profile but whenever I restarted gnome-terminal, it loaded the default profile. So I removed the custom profile and modified directly the “Default” one under Edit -> Profile Preferences.

General tab
Untick the “Use the system fixed width font” if you want to use larger fonts. Monospace 12 is fine for me.

I don’t like blinking cursors and unfortunately you cannot change it here. To disable blinking, you need a little hacking. Execute the following command in a terminal:

gconftool-2 --set "/apps/gnome-terminal/profiles/Default/cursor_blink" --type boolean "False"

This tip is from here.

Colours tab
I’ve always hated that ugly purple background of gnome-terminal. You can get rid of it by unticking “Use colors from system theme”. I prefer the “Gray on black” built-in scheme. Under “Palettes”, I chose the “Linux console” scheme.

Edit -> Keyboard shortcuts…
Here untick “Enable the menu shortcut key (F10 by default)” and then you won’t have any problems with Midnight Commander. For opening new tabs, I prefer the “CTRL + T” shortcut.

Wallpaper Downloader and Rotator for Gnome

April 6, 2011 Leave a comment

Update (20110915): The project has changed a lot since its first release, thus the original post here got completely outdated. I rewrote this blog entry to reflect the current state of the project.


The goal of this project is twofold. First, download images from a wallpaper site. Second, rotate the downloaded images as wallpapers.

Here is the list of changes that I added to the original version:

  • New! XML support is dropped. For setting the images as wallpapers, use the script
  • New! Support for is added!
  • New! Support for is added!
  • Large images can be resized to fit your screen resolution. By default, the maximum width of images can be 1920 pixels. You can customize it in the config file. It’s recommended, this way the images will occupy much less space on your hard drive.
  • You can specify several categories and the downloader will grab images from all these sites. The same is true for rotator: you can specify several categories and it will pick a random image from the whole list. See the config file for more details.
  • The project includes an automatic wallpaper changer script called You don’t need any third-party managers anymore.
  • You can choose from several categories. You can also specify your favorite category.
  • Screen scraping is done with the BeautifulSoup library.
  • The most important change is the filtering of images that are unsuitable as wallpapers, i.e. small images, portrait images, and images with strange ratio are removed from the list.
  • Support for Flickr images (zioyero’s patch).
  • The URLs of the downloaded images are strored in an SQLite database. This way an already fetched image (either good or bad) won’t be downloaded again.

Supported wallpaper sites



First, you might want to customize some settings in the file. The most important thing is the PHOTO_DIR directory, i.e. where to store the downloaded images. Create this directory if it doesn’t exist. Then, simply launch the script:


You can also add it to your crontab:

$ crontab -e 
10 */2 * * * /absolute_path_to/

Add the second line to the end of the crontab list. Here the script is called at every two hours (at 0h10, 2h10, etc.).

For setting the images as wallpapers:

./ & 

That is, just launch it in the background. It uses the same config file as the wallpaper downloader. I put it among my startup applications, thus it starts automatically.


You can download the script from

Related posts

Rotating Gnome backgrounds

April 4, 2011 Leave a comment

You have a bunch of nice wallpaper images that you would like to see on your Desktop. You want Gnome to rotate them in a circular way. Also, specify the duration of an image and the transition between two images.

You need to create an XML file similar to this:

<?xml version='1.0'?>

Here, I rotate three images. One image is shown for 10 seconds and the transition is done smoothly in 5 seconds. After the third image, the first image is shown again, i.e. Gnome will restart processing the file from the beginning.

Usage: You will have to specify this XML file as your background. Right click on the Desktop, Change Desktop Background, Background tab, Add… button. In the bottom right hand corner, switch from Images to All files, then select the XML file. See this screenshot.

Note: Once you set the XML file as your background, you can update it. Gnome will notice the changes and the file will be reloaded. That is, you don’t need to set the file as your background after each modification.


Further reading


Logout from Gnome with a command

March 4, 2011 Leave a comment


It can be necessary sometimes to log out from Gnome and log back in. However, the logout button in the top right hand corner is not always visible, it’s happened to me several times that I couldn’t click on it. How to log out then? Is there a terminal command for this task?


killall gnome-session

Tip from here.

Categories: ubuntu Tags: ,

Open Konsole from Nautilus

March 3, 2011 Leave a comment

The following entry is based on the post “Nautilus Script to Launch a Terminal” by Linerd.


For navigating in the file system, I usually use Midnight Commander. However, sometimes it’s useful to switch to a graphical file manager, which is Nautilus under Gnome. For instance, browsing images with Nautilus is easier since it shows thumbnails. After using Nautilus for a while, I want to continue my work in a terminal (my favorite is konsole) in the current directory. How to do that?

Related work

There is a plugin in the repositories called “nautilus-open-terminal”. By default, the plugin calls gnome-terminal and it seems konsole is not supported :(


In this post, I found a simple and working solution. Here is the script:

#  Nautilus script - terminal-here
#  This script will open a GNOME Terminal in the current directory.
#  Written by Linerd in August, 2009 -
#  Modification:
#  * konsole-here
#  * Open the Konsole terminal emulator in the current directory.
#  Save this script under $HOME/.gnome2/nautilus-scripts/terminal-here. Make sure that
#  you give this file executable permission. { chmod +x terminal-here }
#  This program is free software.  It is distributed in the hope
#  that it will be useful, but WITHOUT ANY WARRANTY; without even
#  PURPOSE.  See the GNU General Public License for more details.

if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then
        DIR=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/^file:\/\///' | sed 's/%20/ /g'`

# gnome-terminal --working-directory="$DIR"
konsole --workdir "$DIR"

exit 0

The konsole modification was suggested by James in a comment in the previously referred post.

Installation: Save it in the directory $HOME/.gnome2/nautilus-scripts under the name konsole-here.

Usage: Right click in Nautilus, then choose Scripts -> konsole-here.

Launch Nautilus from terminal

When I want to launch Nautilus from the terminal, I use the alias “nh”, which stands for “nautilus here”, i.e. open Nautilus in the current directory:

alias nh='nautilus . 2>/dev/null'

Simply put this line in your ~/.bashrc file.

With this alias and with the script above, you can easily switch back and forth between Konsole and Nautilus.


  • Linerd, original script with gnome-terminal support
  • James, konsole patch


There is one thing that troubles me. If I open a konsole from Nautilus, the newly opened konsole gets no focus :( That is, you cannot type immediately, first you need to click on its window. However, if you call the script from the Desktop, konsole gets the focus… If someone has a solution for this, please let me know.

Update (20110304): I think I have a solution for the problem. After switching off the visual effects, konsole gets the focus. Damn… Here is how to get rid of the eyecandy: right click on Desktop -> Change Desktop Background -> Visual Effects tab, select None.

Autologin under Gnome

December 12, 2010 Leave a comment


You want to allow autologin in Gnome. If you are the only person who uses a given machine, with this you can save some time at each boot.


Run gdmsetup as a normal user, unlock it, and allow autologin.

Update (20121020)

Newer versions of Ubuntu use lightdm instead of gdm. So edit the file /etc/lightdm/lightdm.conf and modify these lines under the section [SeatDefaults]:


Tip from here.

Categories: ubuntu Tags: , , ,

Get every new post delivered to your Inbox.

Join 71 other followers