Disabling screensaver on LXDE

Caffeine wasn’t working for me. I got an error like this:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.ScreenSaver was not provided by any .service files

Bug 1280449 contained the solution for me. Thank you Paulius Vitkus:

sudo apt-add-repository ppa:behda/ppa
sudo apt-get remove caffeine
sudo apt-get update && sudo apt-get install caffeine

Android development – saving state

Series: Setup, Menu, Drawing, non-Android, Working, Saving state.

Android apps like Rabbit Escape need to save their state when asked, and restore themselves later. This happens when you rotate the screen, and could happen at various other times. Here’s how I handled that in Rabbit Escape:

Android development – Rabbit Escape really working on Android

Series: Setup, Menu, Drawing, non-Android, Working, Saving state.

Up until now, you weren’t sure to believe my promises that Rabbit Escape really was going to be an Android game, since I hadn’t actually got it running on Android. Well, the wait is over:

Showing urgent (flashing) windows on all desktop in LXDE’s taskbar (window list) in Lubuntu

As it stands, lxpanel’s taskbar plugin (part of the LXDE desktop you get with Lubuntu) does not show urgent (flashing) windows if they are on a different virtual desktop from the one you are looking at.

This seems wrong to me (I logged Bug 682), and the fix is a little one-liner:

--- lxpanel.orig/src/plugins/taskbar.c  2013-08-27 23:57:55.000000000 +0100
+++ lxpanel/src/plugins/taskbar.c       2014-09-26 00:48:25.026855589 +0100
@@ -202,10 +202,10 @@
     tk->flash_timeout = g_timeout_add(interval, (GSourceFunc) flash_window_timeout, tk);
 }
 
-/* Determine if a task is visible considering only its desktop placement. */
+/* Determine if a task is visible considering only its desktop placement and urgency. */
 static gboolean task_is_visible_on_current_desktop(TaskbarPlugin * tb, Task * tk)
 {
-    return ((tk->desktop == ALL_WORKSPACES) || (tk->desktop == tb->current_desktop) || (tb->show_all_desks));
+    return ((tk->desktop == ALL_WORKSPACES) || (tk->desktop == tb->current_desktop) || (tb->show_all_desks) || tk->urgency);
 }
 
 /* Recompute the visible task for a class when the class membership changes.

To install this patch into Lubuntu, do something like this:

sudo apt-get install build-essential fakeroot dpkg-dev
sudo apt-get build-dep lxpanel
mkdir lxpanel
cd lxpanel
apt-get source lxpanel
cd lxpanel-*
wget https://sourceforge.net/p/lxde/bugs/682/attachment/show-urgent-windows-on-all-desktops.patch
patch -p1 < show-urgent-windows-on-all-desktops.patch
dpkg-buildpackage -rfakeroot -b
cd ..
sudo dpkg -i lxpanel_*.deb
killall lxpanel
lxpanel --profile Lubuntu

Launch an urgent window using Python and Xlib with the UrgencyHint flag

I am trying to fix a bug in lxpanel’s taskbar plugin, and needed to launch an urgent window. Here’s how I did it in a little python.

#!/usr/bin/python

# urgent.py -- launch an urgent window (Copyright messages are at the bottom)

# To use:
# sudo apt-get install python-xlib
# ./urgent.py

import sys
import Xlib
from Xlib import X, display, Xutil

d = display.Display()
s = d.screen()
w = s.root.create_window(
    50, 50, 300, 200, 2,
    s.root_depth,
    X.InputOutput,
    X.CopyFromParent,
    background_pixel = s.white_pixel,
)

w.set_wm_name( 'Urgent!' )
w.set_wm_hints( flags = Xutil.UrgencyHint )

w.map()

try:
    while 1:
        e = d.next_event()
except Xlib.error.ConnectionClosedError:
    pass


# This code is based on:
# examples/xrandr.py -- demonstrate the RandR extension
# from http://python-xlib.sourceforge.net/
#
#    Copyright (C) 2014 Andy Balaam
#    Copyright (C) 2009 David H. Bronke
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA