I have recently started using
Kupfer again as my application launcher in Ubuntu MATE, and I found it lacked the ability to suspend the computer.
Here is the plugin I wrote to support this.
To install it, quit Kupfer, create a directory in your home dir called
.local/share/kupfer/plugins, and create this file suspend.py inside: __kupfer_name__ = _("Power management")
__kupfer_sources__ = ("PowerManagementItemsSource", )
__description__ = _("Actions to suspend the computer")
__version__ = "2021-05-05"
__author__ = "Andy Balaam
from kupfer.plugin import session_support as support
class Suspend (support.CommandLeaf):
def __init__(self, commands):
support.CommandLeaf.__init__(self, commands, "Suspend")
return _("Suspend the computer")
class PowerManagementItemsSource (support.CommonSource):
support.CommonSource.__init__(self, _("Power management"))
return (Suspend((["systemctl", "suspend"],)),)
# Copyright 2021 Andy Balaam, released under the MIT license.
Now restart Kupfer, go to Preferences, Plugins, and tick “Power management”.
You should now see a “Suspend” item if you search for it in the Kupfer interface.
Mate Session Management – Kupfer Plugin.
Kupfer Plugin API
The Internet is full of outdated Python code for doing things with windows, so here is what I got working today in a Python 3, GTK 3 environment.
This script toggles the window decorations on the active window on and off. I have it bound to Ctrl+NumPadMinus for easy access.
from gi.repository import Gdk
from gi.repository import GdkX11
from gi.repository import Wnck
for window in screen.get_windows():
if window.is_active() == True:
if w.get_decorations().decorations == 0:
screen = Wnck.Screen.get_default()
display = GdkX11.X11Display.get_default()
window = active_window(screen)
window_id = window.get_xid()
w = GdkX11.X11Window.foreign_new_for_display(display, window_id)
window = None
screen = None
I found something difficult in Python, which was a bit of a first, so I wrote a whole blog series about it, and now a whole video:
Python Async Basics slides
asyncio basics, large numbers in parallel, parallel HTTP requests, adding to stdlib
It was a pleasure to go to the
London Python Meetup organised by @python_london. There were plenty of friendly people and interesting conversations.
I gave a talk “Making 100 million requests with Python aiohttp” (
slides, Blog post) explaining the basics of writing async code in Python 3 and how I used that to make a very large number of HTTP requests.
Hopefully it was helpful – there were several good questions, so I am optimistic that people were engaged with it.
After that, there was an excellent talk by
Gareth Lloyd called “GeoPandas, the geospatial extension for Pandas” in which he explained how to use the very well-developed geo-spatial data tools available in the Python ecosphere to transform, combine, plot and analyse data which includes location information. I was really impressed with how easy the libraries looked to use, and also with the cool Jupyter notebook Gareth used to explain the ideas using live demos.
London Python Meetups seem like a cool place to meet Pythonistas of all levels of experience in a nice, low-pressure environment!
aiohttp / GeoPandas
Because the Rapsberry Pi uses a slightly older Python version, there is a special version of
Graft for it.
Here’s how to get it:
Open a terminal window by clicking the black icon with a “>” symbol on it at the top near the left.
First we need to install a couple of things Graft needs, so type this, then press Enter:
sudo apt install python3-attr at-spi2-core
If you want to be able to make animated GIFs, install one more thing:
sudo apt install imagemagick
To download Graft and switch to the Raspberry Pi version, type in these commands, pressing Enter after each line.
git clone https://github.com/andybalaam/graft.git
git checkout raspberry-pi
Now, you should be able to run Graft just like on another computer, for example, like this:
./graft 'd+=10 S()'
If you’re looking for a fun way to start, why not try the worksheet
“Tell a story by making animations with code”?
For more info, see
Graft Raspberry Pi Setup.