notes by alifeee profile picture tagged linux (3) 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 (+24)

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

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

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