Skip to content

Instantly share code, notes, and snippets.

@lexszero
lexszero / annoy_me
Created April 11, 2021 18:05
A script to annoy the user with sounds and notifications (like `setTimeout()`, but for humans)
#!/bin/bash
set -euo pipefail
export XDG_RUNTIME_DIR=/run/user/1000
readonly SOUND_DIR="/home/lexs/stuff"
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME dunst)/environ)"
echo "DBUS_SESSION_BUS_ADDRESS: $DBUS_SESSION_BUS_ADDRESS"
usage() {
cat <<EOF
Usage: $0 <action> [args..]
#!/bin/bash
xi_dev_id() {
xinput | sed -n "s/.*$1.*id=\\([0-9]\\+\\).*/\1/p"
}
xi_prop_id() {
xinput list-props $1 | sed -n "s/.*$2.*(\\([0-9]\\+\\).*/\1/p"
}
xi_prop_get() {
@lexszero
lexszero / homelexs.zshrc_common
Created December 26, 2017 00:20
/home/lexs/.zshrc_common
[ -f "/etc/DIR_COLORS" ] && eval `dircolors /etc/DIR_COLORS`
cut_term=${TERM#__}
[[ "$cut_term" == rxvt-unicode-256color && "$cut_term" == "$TERM" || -n "$TMUX" ]] && {
precmd () {
print -Pn "\e]0;%n@%M: %~\a"
}
} || {
export TERM=$cut_term
}
unset cut_term
@lexszero
lexszero / homelexs.zshrc_common
Created December 26, 2017 00:19
/home/lexs/.zshrc_common
[ -f "/etc/DIR_COLORS" ] && eval `dircolors /etc/DIR_COLORS`
cut_term=${TERM#__}
[[ "$cut_term" == rxvt-unicode-256color && "$cut_term" == "$TERM" || -n "$TMUX" ]] && {
precmd () {
print -Pn "\e]0;%n@%M: %~\a"
}
} || {
export TERM=$cut_term
}
unset cut_term
@lexszero
lexszero / homelexsbinopen.sh
Created February 3, 2017 10:37
/home/lexs/bin/open
#!/bin/bash -x
BROWSER=${BROWSER:-firefox}
MAX_DL_SIZE=$((20*1024*1024))
say() {
[[ -t 0 ]] && echo "$@" || notify-lexs "Open" "$@"
}
debug() { :; }
[[ -n "$DEBUG" ]] && {
@lexszero
lexszero / homelexsbinyoutube-dl-check.py
Created February 2, 2017 20:30
/home/lexs/bin/youtube-dl-check
#!/usr/bin/python
import sys
from youtube_dl.extractor import gen_extractor_classes
url = sys.argv[1]
suitable = [x.IE_NAME for x in gen_extractor_classes() if x.IE_NAME != 'generic' and x.suitable(url)]
if not suitable:
sys.exit(1)
@lexszero
lexszero / adc.c
Created January 25, 2017 11:26
stm32 adc+dma driver
#include "adc.h"
#ifdef ADC_TABLE
#include "gpio.h"
#include "settings.h"
// configure all channels for 239.5 cycles per sample
#define SAMPLE_TIME 1
#define VREF 2500L
@lexszero
lexszero / printf.c
Created January 17, 2017 13:03
printf() implementation for embedded
/*
File: printf.c
Copyright (C) 2004 Kustaa Nyholm
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.
@lexszero
lexszero / tmpartnet.cpp.cpp
Created January 13, 2017 19:34
/tmp/artnet.cpp
#include "application.h"
#include "settings.h"
#define ARTNET_PORT ((uint16_t)0x1936)
enum {
OpPoll = 0x2000,
OpPollReply = 0x2100,
OpDiagData = 0x2300,
OpCommand = 0x2400,
OpOutput = 0x5000,
@lexszero
lexszero / gpio.c
Created January 10, 2017 11:51
stm32 gpio lib
#include "gpio.h"
#define XGPIO X
#define X(name, port, pin, flags) { port, pin, flags },
gpio_pindef_t gpio_pins[] = {
GPIO_TABLE
BOARD_COIL_TABLE
BOARD_IN_TABLE
};
#undef X