Skip to content

Instantly share code, notes, and snippets.

@s-zeid
s-zeid / show-script-opt.lua
Last active July 30, 2020 11:18
custom command (script message) for mpv to show a script option on the OSD
-- input.conf usage: <key> script-message show-script-opt <opt-name> <default>
-- Example: t script-message show-script-opt osc-title "${media-title}"
mp.register_script_message("show-script-opt", function(name, default)
local value = mp.get_opt(name)
if not (value == nil or value == "") then
value = mp.command_native({"expand-text", value})
else
value = default or "(unavailable)"
end
#!/bin/sh
# <https://gist.github.com/01e327e485cadee4c7c50ba191ae9e9f>
# Workaround for <https://bugs.chromium.org/p/chromium/issues/detail?id=1087937>
# Adapted from /u/ken_duda's comment:
# * <https://old.reddit.com/r/Crostini/comments/gsxx7o/userpid_namespaces_broken_in_crostini_83/fsqn1wj/>
# * <https://bugs.chromium.org/p/chromium/issues/detail?id=1087937#c6>
@s-zeid
s-zeid / opkg-pkgs-from-image
Created July 16, 2020 07:36
Get installed packages from an OpenWrt image (requires p7zip-full)
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $(basename -- "$0") <image-file>" >&2
exit 2
fi
7z -so e "$1" usr/lib/opkg/status \
| grep '^Package:' | cut -d' ' -f 2 | sort
[Service]
TimeoutStopSec=5
@s-zeid
s-zeid / LICENSE.txt
Last active January 31, 2024 08:31
License for my Gists (unless otherwise specified or not eligible for copyright)
Copyright (c) S. Zeid. <https://s.zeid.me/>
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:
The above copyright notice and this permission notice shall be included in
@s-zeid
s-zeid / ec2
Last active August 2, 2021 08:21
(old; moved to https://code.s.zeid.me/bin/blob/main/ec2) Convenience script for EC2 instances
#!/bin/sh
# Requires AWS CLI version 1 (`pip3 install awscli`)
if ! [ -f "$1" ]; then
printf %s "
This script should be used as the shebang line in another script that looks like
the following (assuming this script is on \$PATH):
@s-zeid
s-zeid / media
Last active June 5, 2020 05:30
raspberry pi media tmux window
#!/bin/sh
NAME=media
ACCENT_COLOR='#ab7fcc'
pane_cmd() { echo "echo '\$' $@; $@; PS1='\$ ' exec bash --posix"; }
setup_tmux() {
@s-zeid
s-zeid / silence
Last active May 16, 2020 05:55
Play silence via PulseAudio
#!/bin/sh
# no exec in order to allow checking if the script is running
paplay --raw /dev/zero >/dev/null 2>&1
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family">
<string>Ubuntu Light</string>
</test>
<edit name="family" binding="same" mode="prepend">
<string>Ubuntu</string>
</edit>
@s-zeid
s-zeid / mpv.kwin-translucent-hack.conf
Last active April 10, 2020 21:34
mpv + kwin - Hack to make the window translucent when there is no video track
[kwin-translucent-hack]
# Hack to make the window translucent when there is no video track.
#
# * Set up 2 KWin window rules:
# * class: exact match `mpv`, title: regular expression `\x034f$`
# -> active/inactive opacity: force 50%
# * class: exact match `mpv`, title: regular expression `^[^\x034f]*$`
# -> active/inactive opacity: force 100%
#
# * U+034F is used because KWin strips non-printable characters and replaces