Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GdkX11, Gdk, Gtk
def main():
DEBUG = True
import subprocess
import os
import sys
# This is a function that simplifies calling
# commands. Instead of writing that same try-except
# block over and over, write it once
def run_cmd(cmdlist):
proc = None
#!/usr/bin/env python
from gi.repository import Notify
import subprocess
from time import sleep, time
from sys import argv
import dbus
def send_notification(title, text):
try:
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
import subprocess
import os
import sys
def send_notif(n,title, text):
try:
if Notify.init(__file__):
from gi.repository import GdkX11,Gdk
import subprocess
import time
def run_sh(cmd):
# run shell commands
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
out = p.stdout.read().strip()
return out
#!/bin/bash
set -e # bail if anything goes wrong
is_root(){
if [ "$( id -u )" -ne 0 ] ; then
return 1
fi
return 0
}
#!/bin/bash
# We want to find the directory where all the backlight data
# is stored , based on the fact that there's always "actual_brightness"
# file in that directory
DIR=$(find /sys/devices/ -type f -name "actual_brightness" -printf "%h" )
# Graphic cards all have different integer value for
# maximum level of brightness, so we need to get it
MAX=$(cat "$DIR"/max_brightness )
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gi.repository import Gio,Notify
import dbus
import sys
import os
import time
import subprocess
def get_dbus(bus_type,obj,path,interface,method,arg):
#!/bin/bash
# run script like so: bash thirds.sh NUMBER
# where NUMBER is 0,1 or 2
# 0 is left, 1 is center, 2 is right
get_screen_geometry()
{
# determine size of the desktop
xwininfo -root | \
awk -F ':' '/Width/{printf "%d",$2/3}/Height/{print $2}'
}
#!/bin/bash
list_windows()
{
# get list of all currently open windows
qdbus org.ayatana.bamf \
/org/ayatana/bamf/matcher \
org.ayatana.bamf.matcher.WindowPaths
}