Skip to content

Instantly share code, notes, and snippets.

@coreymwamba
coreymwamba / tasks.nanorc
Created June 7, 2024 15:28
Using nano as a diary/tasks list
syntax tasks "([Tt][Aa][Ss][Kk][Ss]|[Tt][Oo][Dd][Oo])(\.txt)?"
comment "!"
# context (or person)
color brightwhite "\B\@([A-Za-z0-9\-\_]+)"
# hashtag
color brightblue "\B\#([A-Za-z0-9\-\_]+)"
# project
color brightcyan "\B\+([A-Za-z0-9\-\_]+)"
# files/locations
@coreymwamba
coreymwamba / i3-sway.nanorc
Created June 7, 2024 15:23
keyword highlighting in i3/Sway configs
syntax "i3/sway" "(i3|sway)\/config"
color bold,ocher "(^|\s)(exec|exec_always)(\s|$)"
color bold,sage "(^|\s)(seat|workspace|container|window|output|input|bar|for_window|scratchpad)(\s|$)"
color bold,slate "(^|\s)(bindsym|bindswitch|bindgesture|bindcode|floating_modifier|tiling_drag|next|prev|left|right|up|down)(\s|$)"
color bold,orange "(^|\s)(focus|resize|move|split|mode|assign|splith|splitv|stacking|tabbed|floating|set)(\s|$)"
color bold,latte "(^|\s)(border|layout|client|id|swaybar_command|height|font|width)(\s|$)"
color brightyellow start="\[" end="\]"
@coreymwamba
coreymwamba / orddate
Last active May 3, 2022 17:15
dateutils' ordinal date format doesn't doesn't work; and everyone is still writing things in Python, so... ordinal dates in Shell
#!/bin/sh
today=$(date +'%A %e %B %Y') # obviously you can modify this line
D=$(echo $today | grep -E -o "(\b(|[0-3])[0-9]\b)")
case $D in
1|21|31)
mod="st"
;;
2|22)
mod="nd"
;;
@coreymwamba
coreymwamba / arch-wiki-lite-i3-dmenu
Last active May 10, 2020 11:20
Dmenu-driven Arch Linux offine wiki search, using arch-wiki-lite.
#!/bin/bash
# This is just a barebones script -- needs dmenu,arch-wiki-lite, i3-sensible-terminal
# modify as needed
dm="-fn LiberationSans-12 -nb #404452 -sb #9899a0"
s=$(echo "" | dmenu -q $dm -p "ArchWiki")
if [ -n "$s" ]; then
wiki-search "$s" > /tmp/awms
a=$(cat /tmp/awms | awk -F' ' '{ print $2 }')
lines=$(cat /tmp/awms | wc -l)

Keybase proof

I hereby claim:

  • I am coreymwamba on github.
  • I am coreymwamba (https://keybase.io/coreymwamba) on keybase.
  • I have a public key ASDQ_FTSP4fZHGKFFvhevGzlBVbjMHEruL2-Y6V68fFTvQo

To claim this, I am signing this object:

@coreymwamba
coreymwamba / ffpmeg-jack-AV-rec
Last active April 15, 2020 02:28
Records from a camera, and takes audio from a soundcard connected in JACK. Edit variables to taste.
#! env /bin/bash
# ffpmeg-jack-AV-rec - record video from a webcam, audio from a soundcard, using FFMpeg in JACK.
# Corey Mwamba 2018
# You will need jack_autoconnect (https://github.com/kripton/jack_autoconnect)
# And FFMpeg. And JACK.
# the -thread_queue_size option for ffmpeg reduces xruns
FR=25
VC=h264
AC=aac
@coreymwamba
coreymwamba / audio-folder-convert
Last active February 20, 2019 03:16
Bash, inotify, FFMpeg script to convert audio files to a desired format by placing it in a folder. The example below is for Ogg Vorbis; change it to whatever you want. Then set the script to autostart (in DE or WM).
convert_ogg() {
ffmpeg -hide_banner -nostats -loglevel panic -i ~/audio/convert_to_ogg/$file -vn -b:a 320k ~/audio/convert_to_ogg/${file%.*}.flac &
echo "converting $file"
}
while true; do
inotifywait -m ~/audio/convert_to_ogg -e create -e moved_to | while read path action file; do
if [ ${file##*.} != "ogg" ]; then
convert_ogg
fi
@coreymwamba
coreymwamba / simple-ssb
Last active March 26, 2023 15:19
In 2014, I saw a page on Ice SSB (https://peppermintos.com/guide/ice/) which uses the user's browser to create a site-specific browser - I guess what some Android apps do to an extent, or Web Widgets. I then wondered whether it would be possible to do the same but WITHOUT installing a larger browser. Someone else would have done this in Python.
#!/bin/bash
# simple-ssb - a simple Site Specific Browser application
# 2014, 2017 Corey Mwamba
# requirements: Yad/Zenity, WebKitGTK+2, cURL, gjs
# If you need Flash then download the NPAPI Flash plugin
vcheck(){
hash gjs 2>/dev/null || { echo >&2 $(${GUICMD} --text "gjs is not installed"); exit 1; }
hash curl 2>/dev/null || { echo >&2 $(${GUICMD} --text "curl is not installed"); exit 1; }
}
join_strings() {
@coreymwamba
coreymwamba / dictaphone
Last active July 14, 2017 15:19
A quick script to record audio notes. I have this little thing bound to a keypress in JWM (opens in a terminal). Needs ffmpeg.
#!/bin/bash
today=$(date +%s)
echo "press q to stop..."
ffmpeg -f alsa -i hw:0 -v 1 ~/audio-notes/$today.flac $@
@coreymwamba
coreymwamba / start-JACK-on-USB-insert
Last active September 18, 2016 06:16
This is a simple script that brings up a Yad interface when I plug in my USB audio card. The interface then activates JACK. JACK is then killed when I remove the card. You won't be able to do this for a normal user through Udev, since it is a root process. This script is run from the autostart section of my window manager (JWM).
#!/bin/bash
#you will need to modify the device names for JACK...
choose_params() {
qy=$(yad --form --item-separator="|" --field "Purpose:CB" "CD|Live|HD")
jackparams=$(echo $qy | awk -F '|' '{print $1}')
case $jackparams in
CD)
jackd -dalsa -r44100 -p4096 -n3 -D -dhw:Device &
export JACK_SAMPLE_RATE=44100
export JACK_SETTING="REC"