Skip to content

Instantly share code, notes, and snippets.

@philayres
philayres / display-indicator.py
Created October 24, 2011 19:21
Unity indicator for simple clock and date display
#!/usr/bin/env python
# Unity indicator for evolution-less clock and date display
# author: phil ayres
# 24 Oct 2011
import gobject
import gtk
import appindicator
import os, sys
import time
@jadonk
jadonk / epolltest.c
Created May 3, 2012 17:41
Quick test using epoll to wait on GPIO events
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <sys/types.h>
int main(int argc, char** argv) {
@inean
inean / compositor.py
Created May 29, 2012 18:00
A class to interact with Harmattan compositor
from os import getpid
class HarmattanCompositor(object):
# Atoms
XA_ATOM = 4
XA_STRING = 31
XA_WINDOW = 33
# Contants
@nealmcb
nealmcb / track_session_inhibitors.py
Created July 16, 2012 05:19
Track and print out the apps and clients that are inhibiting Gnome session actions like log out, user switching, suspending or idle/dpms/screensaver, under Linux.
#!/usr/bin/python
"""
Print out the apps and clients that are inhibiting session actions like log out, user switching, suspending or idle.
%InsertOptionParserUsage%
Example:
track_session_inhibitors &
Todo:
@akatrevorjay
akatrevorjay / getkwargs.sh
Last active March 23, 2017 03:20
Python-esque arguments for Bash. If you like this, check out https://github.com/akatrevorjay/bashism
#!/bin/bash -e
# ____________
# getkwargs.sh
#
# -- Gives you simple Python-esque arguments in Bash
# ie: your_function_or_script never=always sync daemon=True
#
# TODO Enhance interface with standard opts support: -p|--path[=blah]
#
# ~trevorj 05/05/2013
@oktayacikalin
oktayacikalin / mount.py
Created October 20, 2013 07:14
How to mount a local volume using gvfs (gio) in Python 3 - quick and dirty.
#!/usr/bin/env python3
# Quick and dirty implementation of mounting a local volume using Gio.
# For people who were scratching their heads like me.
# Code below based on infos from:
# http://stackoverflow.com/questions/5709454/gio-check-if-volume-is-mounted
# http://stackoverflow.com/questions/1991206/accessing-samba-shares-with-gio-in-python/2051628#2051628
#!/usr/bin/env python
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
#
# Copyright (C) 2010 Red Hat, Inc., John (J5) Palmieri <johnp@redhat.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
@johnlane
johnlane / dockbar-gtk2.py
Last active July 14, 2024 09:01
Example GTK to create a dock-like bar and strut
#!/usr/bin/env python2
#
# dockbar.py
#
# Example program places a coloured bar across the top of the
# current monitor
#
# demonstrates
#
# (a) creating the bar as an undecorated "dock" window
@dyerw
dyerw / coroutines.py
Created January 6, 2015 17:09
A simple producer/consumer example using python coroutines
import random
def coroutine(func):
"""A decorator to automatically prime coroutines"""
def start(*args, **kwargs):
cr = func(*args, **kwargs)
next(cr)
return cr
return start
@nathan-osman
nathan-osman / ip-indicator.py
Last active April 2, 2018 23:37
IP Address AppIndicator
#!/usr/bin/env python2
import appindicator
import gtk
import urllib2
class IPIndicator(appindicator.Indicator):
"""
An indicator displaying public IP address.