Skip to content

Instantly share code, notes, and snippets.

@SergKolo
SergKolo / link_windows.py
Last active March 31, 2024 04:23
A script that allows linking two windows together such that switching focus on one, brings up the other as well
#!/usr/bin/env python3
# Author: Serg Kolo
# Date: Oct 3rd, 2016
# Description: Script for aligning the center of
# user's active window with the center of the monitor
# Tested on: Ubuntu 16.04
# Written for: http://askubuntu.com/q/832720/295286
from __future__ import print_function
import gi
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Author: Sergiy Kolodyazhnyy
Date: August 2nd, 2016
Written for: http://askubuntu.com/q/806212/295286
Tested on Ubuntu 16.04 LTS
usage: dynamic_mouse_speed.py [-h] [-q] [-p POINTER] [-s SCROLL] [-v]
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__):
#!/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}'
}
#!/usr/bin/env python3
# Author: Serg Kolo
# Date: Oct 3rd, 2016
# Description: Script for aligning the center of
# user's active window with the center of the monitor
# Tested on: Ubuntu 16.04
from __future__ import print_function
from gi.repository import Gdk,Gio
#!/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:
@SergKolo
SergKolo / Simple "ring buffer" table
Created July 19, 2020 05:03
Simple "ring buffer" table. Mainly intended to be the most basic example of how logging can be implemented in SQLite
DROP TABLE IF EXISTS ring_log;
CREATE TABLE ring_log (
timestamp INT,
data TEXT
);
CREATE TRIGGER remove_oldest BEFORE INSERT ON ring_log
WHEN ( SELECT COUNT(*)>5 FROM ring_log )
BEGIN
DELETE FROM ring_log WHERE timestamp in ( SELECT timestamp FROM ring_log LIMIT 1 );
@SergKolo
SergKolo / qdbus_windows.sh
Created April 24, 2016 03:19
listing apps and their windows with qdbus
#!/bin/bash
get_window_paths()
{
qdbus org.ayatana.bamf /org/ayatana/bamf/matcher org.ayatana.bamf.matcher.WindowPaths
}
get_running_apps()
{
qdbus org.ayatana.bamf /org/ayatana/bamf/matcher org.ayatana.bamf.matcher.RunningApplications
@SergKolo
SergKolo / minicat.c
Created November 29, 2019 09:49
Basically simplified example from getline(2) man page with optional stdin vs file reading
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE *stream;
char *line = NULL;
size_t len = 0;
ssize_t nread;