notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (19), scripting (5), bash (4), linux (3), html (2), markdown (2), obsidian (2), shortcuts (2), ActivityPub (1), advent-of-code (1) ............ see all (+15)

starting radio station streams with shortcuts on Linux Pop!OS # prev single next top

tags: shortcuts, linux, radio • 310 'words', 93 secs @ 200wpm

I enjoy listening to the radio. I enjoy listening to music. I don't enjoy listening to adverts. BBC Radio 6 Music fits these requirements well. So do two of my local Sheffield radio stations: Forge radio and mondo.radio.

I have a physical radio in my kitchen, but on my laptop or computer I enjoy using HTTP audio streams. For the latter two radio stations, I opened the network tab in my web browser, and clicked play, and then saw a request pop up. I copied this and I can use it either in a new tab in my browser, or as a "Network stream" in VLC Media Player. For BBC Radio 6 Music, I can't remember how I found the stream. I just tried to find a copy in the network requests tab, but I couldn't. I did find two articles about it: https://garfnet.org.uk/cms/2023/10/29/latest-bbc-hls-radio-streams/ and https://minimradio.com/. Anyway, I still have the URL, so I can launch it (and the others) in VLC by using:

# forge radio
vlc "http://solid41.streamupsolutions.com:10062/;stream.nsv"
# mondo radio
vlc "https://streamer.radio.co/s1afcca186/listen"
# bbc radio 6 music
vlc "https://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_6music/bbc_6music.isml/bbc_6music-audio%3d96000.norewind.m3u8"

I'm enjoying creating shortcuts on my computer, so I turned the above three commands into shortcuts. Now I can launch the radios in VLC with the push of a (well, four) button.

SUPER + CTRL + SHIFT + 4 --- "Four"-ge radio
SUPER + CTRL + SHIFT + 5 --- mondo radio (no pun for this one)
SUPER + CTRL + SHIFT + 6 --- BBC Radio "6" music
back to top

how I organise my notes (project-active-resource-archive) # prev single next top

tags: obsidian, note-taking • 584 'words', 175 secs @ 200wpm

I make a lot of notes¹. Currently, I use Obsidian on my computer, laptop, and phone, and I use Syncthing to synchronise all the notes between my devices. I like making notes because if I write something down, I don't have to worry about forgetting it, and (maybe backwardsly) I can forget it with ease... because I know where I can go to remember it. It frees up my brain a lot. No thoughts. Head empty.

¹ At time of writing I have 1018 notes (result of find . -type f -name "*.md" | wc -l) (the Notion -> Obsidian export makes all database items into notes, so this is quite inflated by a bunch of empty "database" notes).

I used to use Notion but I realised: I would prefer to be making plaintext notes; I didn't like what they were doing with AI; the app was quite slow to use; and I had to be online (a lot of the time) to use it. With Obsidian, I can write notes offline, and they are only ever stored on my own devices, and synced between them.

I have four folders in the root folder of my obsidian, these are

1-Project
2-Active
3-Resource
4-Archive

This layout is called "PARA" (Project Active Resource Archive). I found out about it several years ago; I don't remember where.

The theory (or how I use it) is that you organise notes like:

So, as an example, my current:

There are many ways to organise notes, but I like this way because I can always pretty obviously fit a note into one of the three categories, so I don't have to constantly move notes around, or think too much about where they belong. Also, every few years it feels pretty great to empty out the project notes folder (an impossible task).

back to top

turning my clipboard into a blockquote on Linux # prev single next top

tags: scripting, linux, markdown • 237 'words', 71 secs @ 200wpm

I like markdown. I use Obsidian a lot, and write a lot in GitHub issues. Something useful I usually do is quote other people's words, so in markdown it would look like:

The Met office said

> it will definitely snow tonight
>
> like... 100%

I found that I can use a command xclip to get/set my clipboard on Linux, and I use a lot of sed to do word replacement, so I realised I could copy the text

it will definitely snow tonight

like... 100%

and then run this command in my terminal (xclip gets/sets the clipboard, sed replaces ^ (the start of each line) with > )

xclip -selection c -o | sed "s/^/> /" | xclip -selection c

which would get my clipboard, replace the start of each line with a quote, and set the clipboard, setting the clipboard to:

it will definitely snow tonight

like... 100%

I've set aliases for these commands so I can use them quickly in my terminal as:

alias getclip='xclip -selection c -o'
alias setclip='xclip -selection c'
alias quote='getclip | sed "s/^/> /" | setclip'

but also I created a keyboard shortcut in Gnome, CTRL + SUPER + Q, which will quote my clipboard. I had to set the shortcut to run bash -c 'xclip -selection c -o | sed "s/^/> /" | xclip -selection c' as I don't think pipes sit well in shortcuts.

But now I can really easily...

quooooooooote

back to top

on procrastination # prev single next top

tags: procrastination • 522 'words', 157 secs @ 200wpm

a while ago (maybe an hour), I opened my to-do list. Here is the tale that follows of the resulting procrastination. Too much in life it is possible to convince yourself that everyone else is more organised than you because you only see the final product. So, this is one miniature combat against that idea.

I opened obsidian
on my todo list it said "make a christmas list"
I thought I had made one before, so I looked in my "resource" folder
I found a hitchhiking list
it didn't have my latest hitchhike on there, so I added it
at the same time, I hadn't edited the page since I exported it from Notion, so it was badly formatted
I fixed the formatting, and while doing so remembered...
I have a note on my phone about the people I've met hitching (this note was only about the service stations visited)
I opened my notes app to find it
I found a note about android keyboards from when I switched keyboard
I wanted to delete it but first posted decided I could post a note about it
just after starting to write it, I got a notification about the 2025 toki pona meetup
I went to quickly fill in the form, because everyone's opinion is valid
on there I saw a link to ma.pona.la (a collaborative map of toki pona speakers)
I opened it since I requested to be added a while ago and hadn't looked to see if I was on there yet
I was impressed by the number of people as I scrolled around the map
I realised I'm going to Dublin and Hamburg soon so messaged people there just out of interest
I got distracted on the personal websites I found of the people I messaged
I changed my Discord profile picture and description as it was outdated
I got back to writing note about keyboards
I linked to switching.software in the introduction, so...
I went to look if switching.software had any mention of android keyboards
there were none on the website, and none in the issues
I finished the note, and linted it
markdownlint complained about 4 spaces instead of 2 in lists, which is the default in Obsidian
so I found out how to write a json rule file for markdownlint to change rule from 4 spaces to 2 spaces
I posted the note to my website (https://blog.alifeee.co.uk/notes/choosing-a-free-and-open-android-keyboard/) and mastodon
I created a Codeberg account to post an issue to switching.software
I created an issue about Android keyboards in switching.software codeberg
I remembered what I initially set out to do (create a Christmas list) and that I had not done it
I realised this would be nice to document my "thought train" as a procrastination story
the time is now

I hope you can do what you want to do today.

back to top

choosing a free and open Android keyboard # prev single next top

tags: android, free-software • 485 'words', 146 secs @ 200wpm

A few months ago I was trying to find a keyboard to replace SwiftKey (Microsoft's Android keyboard). The other behemoth in the arena is GBoard, Google's Android keyboard. I didn't want to use either of these because... they're privacy-invading megacorps. My morality aligns more with that of switching.software or this page on digital solidarity networks.

What I wanted

I wanted to find a keyboard that had:

What I chose

(spoilers) I ended up choosing FUTO keyboard, as it seemed ethically good, even though I don't fully enjoy the story of the FUTO organisation. From the about page - it seems fully funded and fully run by one rich guy who escaped silicon valley. I'd rather something more cooperatively minded, but hey-ho.

After using it for a few months, I have gotten used to its quirks (such as not autocorrecting if you are typing a word in between words not separated by a space, etc) and I am not regretting switching nor missing SwiftKey.

The others

Here are the others I considered:

back to top

getting latlong coordinates from an address with geocode.xyz # prev single next top

tags: scripting, maps • 369 'words', 111 secs @ 200wpm

I like maps. I make maps. Mostly from worse maps or data that is not in map form. See some of mine on https://alifeee.co.uk/maps/.

One thing I've been doing for a map recently is geocoding, which is turning an address (e.g., "Showroom Cinema, Paternoster Row, Sheffield") into latitude/longitude coordinates.

https://geocode.xyz/ provides a free geocoding API on https://geocode.xyz/api which is rate limited to one request per second.

Here is a script to wrap that API for using it as a script. It's not amazing but it works.

#!/bin/bash

loc="${1}"
throttled=1

while [ $throttled = 1 ]; do
  resp=$(curl -s -X POST -d locate="${loc}" -d geoit="json" "https://geocode.xyz")
  if [[ "${resp}" =~ Throttled ]]; then
    echo "throttled... retrying..." >> /dev/stderr
    throttled=1
  else
    throttled=0
  fi
  sleep 1
done

echo "got response: ${resp}" >> /dev/stderr

json=$(echo "${resp}" | jq | sed 's/ {}/""/g')

basic=$(echo "${json}" | jq -r '
.latt + "\t" +
.longt + "\t" +
.standard.confidence + "\t"'
)

standard=$(echo "${json}" | jq -r '
.standard.addresst? + "\t" +
.standard.statename? + "\t" +
.standard.city? + "\t" +
.standard.prov? + "\t" +
.standard.countryname? + "\t" +
.standard.postal? + "\t"
')

alt=$(echo "${json}" | jq -r '
.alt?.loc?.addresst + "\t" +
.alt?.loc?.statename + "\t" +
.alt?.loc?.city + "\t" +
.alt?.loc?.prov + "\t" +
.alt?.loc?.countryname + "\t" +
.alt?.loc?.postal + "\t"
')
echo "${basic}${standard}${alt}" | sed '1s/^/latitude\tlongitude\tconfidence\taddress\tstate\tcity\tprovince\tcountry\tpost code\talt address\talt state\talt city\talt province\talt country\talt postal\n/'

and then you can use it like

$ ./geocode.sh "Showroom Cinema, Paternoster Row, Sheffield"
throttled... retrying...
throttled... retrying...
got response: {   "standard" : {      "stnumber" : "1",      "addresst" : "Paternoster Row",      "statename" : "England",      "postal" : "S1",      "region" : "England",      "prov" : "UK",      "city" : "Sheffield",      "countryname" : "United Kingdom",      "confidence" : "0.9"   },   "longt" : "-1.46544",   "alt" : {},   "elevation" : {},   "latt" : "53.37756"}
latitude	longitude	confidence	address	state	city	province	country	post code	alt address	alt state	alt city	alt province	alt country	alt postal
53.37756	-1.46544	0.9	Paternoster Row	England	Sheffield	UK	United Kingdom	S1

The results are "ok". They're pretty good for street addresses, but I can see a lot of wrong results. I might try and use another API like OpenStreetMap's or (shudders) Google's.

back to top

serving a random image with a CGI script # prev single next top

tags: cgi • 146 'words', 44 secs @ 200wpm

I made this because I have hundreds of images of myself and what I have been doing from BeReal.

I stopped using it because the company got big and evil (booo), so I requested all my data (images) and I (will soon) request them to remove that data.

But, for the meanwhile, I've been screwing around with it. I made a timelapse, but also fun is a random image picker.

I put all the images on my server, and made a very simple CGI script:

#!/bin/bash

file=$( (cd /var/www/; find images/ -type f -not -name "*index.html" \
  | sort --random-sort | head -n1) )

echo "HTTP/1.1 302 Found"
echo "Location: /${file}"
echo ""

now I can access /.../random.cgi and it redirects me to an image, served by nginx. Sweet.

I would like to write a bigger blog about CGI scripts in future.

back to top

copy my most recent screenshot on Pop!_OS Gnome Linux # prev single next top

tags: linux, shortcuts • 597 'words', 179 secs @ 200wpm

I recently started using Pop!_OS, which uses Gnome as a desktop environment.

What's the problem? my clipboard history doesn't do images

Apparently there are a few different "clipboards" in desktop Linux, but I like to ignore this fact and pretend there is only one.

I like clipboard history, so that I can copy several things, switch application, and then paste several things (like copying both username and password). As such, I installed a Gnome extension "clipboard indicator" to have a clipboard history: https://extensions.gnome.org/extension/779/clipboard-indicator/.

However, it doesn't have images on there, only text. So, if you copy an image (or take a screenshot), then copy some text, you can't use the clipboard history to get back to the image - you have to re-copy it or re-take the screenshot. I find this a bit annoying.

my clipboard history does have support but not for my version of Gnome

A note: image support was added, but only in Gnome 45 (which is not very obvious). I am on Gnome 42.9, and I don't understand enough about Linux distributions to know if I can upgrade that version myself, or it is built into Pop!_OS. It seems like Pop!_OS is creating a whole new Desktop environment anyway, for some reason, so they may never reach Gnome 45.

changing where screenshots are stored

Let's work around the problem. But first, Screenshots are saved to ~/Pictures/Screenshots, which can't be changed (easily). However, an aside: I want to change it because I sync my ~/Pictures/ folder to my phone with Syncthing, and I don't want ephemeral screenshots clouding my phone.

First, I tried changing dconf settings by installing dconf-editor with sudo apt install dconf-editor, and I found a setting called org.gnome.totem > screenshot-save-uri. I changed this from "" to .cache, but it did nothing. It turned out it was entirely unrelated, as "gnome totem" is some sort of video player. So, instead, I moved the Screenshots directory manually and created a symbolic link with

mv /home/alifeee/Pictures/Screenshots /home/alifeee/.cache/Screenshots
ln -s /home/alifeee/.cache/Screenshots /home/alifeee/Pictures/Screenshots

copying the latest screenshot to the clipboard

with some searching, I found a way to use xclip to copy an image to the clipboard, like this:

xclip -selection clipboard -target image/png -i "Screenshot from 2024-11-11 10-28-31.png" 

creating a keyboard shortcut to copy the latest screenshot

with Gnome you can create keyboard shortcuts, so I wanted to map CONTROL + SUPER + C to "copy latest screenshot". I struggled getting the command to output anything, and eventually wrapped the whole command (that I got working in my terminal) in quotes and slapped bash before it, and it works great now. After installing libnotify-bin, I created the keybind with this command:

bash -c 'dir=~/Pictures/Screenshots/; img=$(ls -t "${dir}" | head -n1); xclip -selection clipboard -target image/png -i "${dir}${img}"; notify-send "copied image" "${img}"'

Now I press CTRL+SUPER+C and I get a notification on the top of my screen telling me I copied an image, and I can paste the image anywhere I can usually paste images!

Sweet.

back to top

what's the best messaging app # prev single next top

tags: privacy, software • 314 'words', 94 secs @ 200wpm

Recently some of my friend group wanted to move messaging app. We were using Instagram. For me this was a great opportunity to promote the good word of God encryption and privacy, and also make a proto-comparison matrix of different apps, as every comparison matrix is biased, usually to whoever's website you're on. In this case, I provide the bias.

Instagram is only on the list because this was a proposal to move away from Instagram, and WhatsApp is only there because everyone I personally know whines and says "but eeeveryone has WhatsApp". Currently, I'm mostly using Telegram and Signal to message people.

The list of features is just from me imagining what I want, what I've experienced before, and clicking around on various apps and seeing what they have (e.g., Signal's story feature - does anyone use this???)

key:

features:

high quality photos 🟩🚙👁️‍🗨️
voice notes 🟩📸🚙👁️‍🗨️
video notes 🟩📸🚙👁️‍🗨️
sharing location 🟩🚙👁️‍🗨️
sharing files 🟩🚙👁️‍🗨️
editable theme/colours 🟩📸👁️‍🗨️
private (encrypted) 👁️‍🗨️
can delete history automatically 🟩🚙👁️‍🗨️‡
see image feed 🟩📸🚙👁️‍🗨️
see file feed 🟩🚙👁️‍🗨️
see link feed 🟩🚙
can mute for a period of time 🟩📸🚙👁️‍🗨️
can share to it easily 🟩📸🚙👁️‍🗨️
can pin messages 🟩†🚙
custom reactions 🟩📸👁️‍🗨️
polls 🟩🚙
formatting (italics/bold/etc) 🟩🚙👁️‍🗨️
spoiler text 🚙👁️‍🗨️
group story 👁️‍🗨️
disappearing images 🟩📸🚙👁️‍🗨️
group description 🟩🚙👁️‍🗨️

† only for short time ‡ yea but it looks super annoying

options not considered here, for a multitude of reasons (feel free to guess why):

We ended up moving to Signal.

P.S., it is possible that I have a Western bias against Telegram, I enjoyed this podcast about Signal but it did feel that some of the criticisms were just "it's not an app controlled by the USA": https://logbuch-netzpolitik.de/lnp504-the-politics-of-intellectual-shame

back to top

basic HTML template with all the gubbins # prev single next top

tags: html • 235 'words', 71 secs @ 200wpm

I create a lot of websites. I'm also a big fan of very performant, very accessible websites. I'm also a big fan of the phrase "the important thing first is for a webpage to exist, then after that to look nice".

With that in mind, this is the HTML template I usually start with to make a new webpage. It's made to manually replace the things in curly brackets, but also has the bonus that you could use it with a templating language like https://handlebarsjs.com/ (my favourite).

<!DOCTYPE html>
<html lang="en">

<head>
    <!-- browser metas -->
    <title>{{title}}</title>
    <meta name="description" content="{{description}}" />
    <!-- allow unicode characters -->
    <meta charset="utf-8" />
    <!-- 'zoom' on mobile -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- embed metas - https://ogp.me/ - visible when sharing on social media -->
    <meta property="og:title" content="{{title}}" />
    <meta property="og:type" content="website" />
    <meta property="og:site" content="{{title}}" />
    <meta property="og:url" content="{{base_url}}/{{page}}" />
    <meta property="og:image" content="{{base_url}}/{{image}}" />
    <meta property="og:description" content="{{description}}" />
    <meta property="og:locale" content="en_GB" />

    <!-- styling -->
    <!-- favicon - can be any image (.png, .jpg, .ico) -->
    <link rel="icon" type="image/png" href="/og-image.png" />
</head>

<body>
    <header></header>
    <main>
        {{{content}}}
    </main>
    <footer></footer>
</body>

</html>

Put it somewhere, and put something in there! Make a personal website! Make a blog! I will love you forever.

back to top see more (+9)