Skip to content

Instantly share code, notes, and snippets.

@Darkhogg
Darkhogg / !RebootToOs.md
Last active April 22, 2024 09:20
"Reboot to {OS}" scripts for rEFInd Next Boot selection

Reboot to {OS}

This a collection of notes and files used in my quest to create "Reboot to Windows" and "Reboot to Linux" scripts (and desktop shortcuts) for Linux and Windows respectively that automatically reboot my system and instruct rEFInd to auto-select the appropriate OS entry.

General Information

The key for achieving this is to modify the EFI Variable PreviousBoot with GUID 36d08fa7-cf0b-42f5-8f14-68df73ed3740, which rEFInd uses to store the last entry selected in the menu and, if using the + default entry, will be used to select the default OS. By doing this, we trick rEFInd into booting the OS we choose without having to be physically there to press the keyboard.

@Darkhogg
Darkhogg / GetIconTheme.md
Created October 5, 2023 22:22
Get Icon Theme in every Desktop

Get Icon Theme in Every Desktop

If you've ever tried to manually look for the current icon theme, you've probably come to the (correct) conclusion that it's simply impossible to do it in a portable way: each desktop environment in existence stores that information in a different place, and it's none give out that info in a common way.

In order to find out the current icon theme then, we first need to find out the current desktop environment and only then we can get the current icon theme in a desktop-dependent way. To do that, we can use the following environemnt variables:

  • XDG_SESSION_DESKTOP: contains the name of the current session name.
  • XDG_CURRENT_DESKTOP: contains a :-separated list of current desktop names.
@Darkhogg
Darkhogg / !FactorioDokku.md
Last active January 26, 2018 07:41
Factorio Headless Server on Dokku

Factorio Server on Dokku

This document and associated files describe a very simple procedure to push a Dokku application that will launch a Factorio Multiplayer Server. This are the actual files used to launch my Factorio server, so you should trust that it works.

Dokku Setup

@Darkhogg
Darkhogg / G203SlowDimCycle.py
Created January 19, 2018 21:32
Set slow and dim color cycle for G203 Mouse
import usb.core
import usb.util
import binascii
VENDOR = 0x046d
PRODUCT = 0xc084
INDEX = 0x0001
REQUEST_TYPE = 0x21
REQUEST = 0x09
VALUE = 0x0210
@Darkhogg
Darkhogg / kakuro-sums.json
Last active June 12, 2017 10:48
List of Kakuro sums
{
"n1_s1": [
[1]
],
"n2_s1": [
[2]
],
"n3_s1": [
[3]
],

Keybase proof

I hereby claim:

  • I am darkhogg on github.
  • I am darkhogg (https://keybase.io/darkhogg) on keybase.
  • I have a public key whose fingerprint is 64E3 1E88 08F4 25B1 400A 33F2 9DC6 A8F0 4AAD D567

To claim this, I am signing this object:

@Darkhogg
Darkhogg / genmon-loadavg.py
Last active March 5, 2016 16:17
Generic Monitor script for Xfce that shows the normalized load average in color
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division
import multiprocessing as mp
import os
import sys
KEYPOINTS = (
@Darkhogg
Darkhogg / okko.sh
Last active December 19, 2015 07:09
A shell function that executes a command and tells if it succeeded or failed with customizable output.
#$ okko [opts] message command [args]*
#
# This shell function provides a way to run a command and present its result
# in a user-friendly way.
#
# The provided message is initially printed to the screen, then the command is
# run with the given arguments. After command completion, 'ok' is printed if
# the command exited with a tatus of 0, else 'err(N)' is printed, where N is
# the error code.
#
@Darkhogg
Darkhogg / PeriodicScrot
Last active October 3, 2015 08:38
A small script that uses `scrot` to periodically save screenshots from the desktop.
./capture [-h] [-p period] [-d directory]
* Use **-h** to print the above usage line.
* Use **-p period** to specify the period of the screenshots, in seconds. The *period* argument must be a positive integer. Defaults to *15* seconds.
* Use **-d directory** to specify the directory where the screenshots will be saved. The specified directory must exist and be writable. Defaults to the current working directory (which may be not writable, which won't cause an immediate error, but will make scrot fail).
In order to this script to work, you need to have the `scrot` command installed on your PATH.
The script may be paused by sending an interrupt signal (`SIGINT`), typically by pressing the `CTRL-C` key combination. When the script is paused, you may resume it by pressing `ENTER` or end it with another `CTRL-C`.