Not always, but sometimes when I need[1] to concentrate™, I put some music/noise on. Either through headphones or the speaker. FIP often fills silence satisfactorily. Brown noise also works.
Sometimes I turn to youtube for long background tracks like the ten-hour long White Noise Sounds of Frozen Arctic Ocean with Polar Icebreaker Idling. Or, clichéd as it may be, I do also quite like the lofi girl streams, specifically the "lofi hip hop radio beats to relax/study to".
the problem
It's not really a problem, but it bugs me to have to have a browser window with youtube open.
the solution
Some fragile python code, a bash script, a function and an alias in my .bashrc file, which altogether mean I can type streamurl in my terminal, and the music/noise just plays.
VLC's GUI doesn't even open because we used cvlc instead of just vanilla vlc. There are a few more lines of python that mean if I don't pass pass a url, it'll deafult to "lofi hip hop beats to relax/study to".
To stop it I tiptap: streamstop.[2]
(some of) the python
import yt_dlp
def play_stream(url):
ydl_opts = {
'quiet': True,
'no_warnings': True,
'extract_flat': False,
'format': 'best',
'skip_download': True
}
# get the streaming url
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url, download=False)
if 'url' in info:
stream_url = info['url']
# run vlc
vlc_cmd = [
"cvlc",
stream_url,
"--no-video",
"--quiet"
]
# make it quiet, and make pid accessible
process = subprocess.Popen(
vlc_cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
# get pid and store pid
pid = process.pid
with open("/tmp/streaming.pid", "w") as f:
f.write(str(pid))
print(f"pid ({pid}) written to /tmp/streaming.pid")
the bash script
#! usr/bin/env bash
source /home/myUserName/micromamba/etc/profile.d/mamba.sh
micromamba activate yt
python3.14 /home/myUserName/Documents/projects/streamyt/play_url.py $1
the bash function
streamurl() {
"bash" "/home/myUserName/Documents/projects/streamyt/play_url.sh" "$1"
}
the alias
alias streamstop="pkill -f vlc"