Skip to content

Instantly share code, notes, and snippets.

@ryot4
ryot4 / slock-add-color3.diff
Created September 9, 2014 06:10
A patch which adds COLOR3 to slock (http://tools.suckless.org/slock/)
diff --git a/config.mk b/config.mk
index 8cc3f68..941e265 100644
--- a/config.mk
+++ b/config.mk
@@ -14,7 +14,7 @@ INCS = -I. -I/usr/include -I${X11INC}
LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext
# flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\"
+CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" -DCOLOR3=\"\#333333\"

How to setup a minimal X11 environment on Debian GNU/Linux

  1. Install the following packages

    • xserver-xorg-core (server)
    • xserver-xorg-video-XXX (video driver, XXX depends on your hardware)
    • xserver-xorg-input-XXX (input device driver, XXX depends on your hardware. evdev works well for most cases)
    • x11-xserver-utils (xmodmap, xrandr)
    • x11-xkb-utils (setxkbmap)
  • x11-utils (xdpyinfo, xev, xkill, xprop, xwininfo)
#!/bin/sh
screenshot_root=~/Pictures/screenshot
viewer='xdg-open'
while getopts 'd:n:v' opt; do
case "$opt" in
d) dir="$OPTARG" ;;
n) name="$OPTARG" ;;
v) scrot_execute="$viewer \$f"
#!/bin/sh
host=$(grep '^Host' ~/.ssh/config | \
cut -d \ -f 2 | \
dmenu $DMENU_OPTIONS -p 'ssh to:')
exec urxvtcd -title "ssh: $host" -e ssh "$host"
#!/bin/sh
xephyr_options="-ac -screen ${1:-800x600}"
xephyr=$(which Xephyr)
if [ -z "$xephyr" ]; then
echo 'Xephyr not found'
exit 1
fi
startx "$HOME/.xephyr_session" -- "$xephyr" $xephyr_options
@ryot4
ryot4 / xmovewin.sh
Created September 7, 2016 13:24
Move the active X11 window in the specified direction
#!/bin/sh
# dependency: xdotool and wmctrl
eval $(xdotool getactivewindow getwindowgeometry --shell)
DESKTOP=$(wmctrl -d | awk '{ print $4 }' | tr x ' ')
DWIDTH=$(echo $DESKTOP | cut -d ' ' -f 1)
DHEIGHT=$(echo $DESKTOP | cut -d ' ' -f 2)
case $1 in
left)
@ryot4
ryot4 / get-release-download-count.rb
Created February 26, 2020 15:15
Get the number of downloads for each release asset
#!/usr/bin/env ruby
require 'octokit'
client = Octokit::Client.new(:access_token => '<personal_access_token>')
client.releases('<user>/<repo>').each do |rel|
puts rel.name
client.release_assets(rel.url).each do |asset|
puts "#{asset.name} #{asset.download_count}"
@ryot4
ryot4 / gen-ula-prefix.sh
Last active May 3, 2020 15:52
Generate IPv6 Unique Local Address prefix (https://tools.ietf.org/html/rfc4193#section-3.2.2)
#!/bin/sh
# Copyright (c) 2020 ryot4
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ryot4
ryot4 / terminal-color-sequence.sh
Last active May 16, 2020 14:46
Table of ANSI color escape sequence combinations
#!/bin/sh
for bg in '' $(seq 40 47 | sed 's/^/;/'); do
for bold in '' 1; do
for fg in '' $(seq 30 37 | sed 's/^/;/'); do
code="${bold}${fg}${bg}"
code="${code#;}"
printf '\033[%sm %7s\033[0m' "${code}" "${code}"
done
printf '\n'
@ryot4
ryot4 / venv.bash
Last active May 30, 2020 18:16
A Bash wrapper function for Python venv
venv()
{
local venv_dir
if [[ -n $VENV_ROOT ]]; then
venv_dir="${VENV_ROOT}/${2:-$(basename ${PWD})}"
else
venv_dir=.venv
fi