I Spent Hours Automating a 0.5 Second Task (And It Was Worth It)
Building a time-based audio automation script for Fedora that switches between speakers and headphones at login — because manually clicking is for peasants. You know that bone-deep exhaustion from doing the same tiny task over and over? Yeah, I got tired of manually switching between my Speakers and 3.5mm headphones every time I boot up. It’s not that I forgot. It’s that I’m lazy and got sick of clicking the same two buttons every single day. So naturally, I did what any reasonable developer would do: spent an entire evening building an automation script to save myself 0.5 seconds of clicking. My setup is simple: But manually switching got old fast. Boot up at 10 PM and have to switch to headphones. Boot up at 8 AM and switch back to speakers. Every. Single. Time. Nah, I’m done with that. Built a bash script that runs at login and automatically switches based on time: Of course I couldn’t just write a simple script. It had to be bulletproof: The script is way smarter than it needs to be. Classic over-engineering. From a time perspective? Absolutely not. I’ll never recoup those hours. From a “my computer now reads my mind” perspective? Hell yes. Every boot, the right audio device is just there. No thinking, no clicking, no repetitive strain on my clicking finger. That’s the beauty of personal automation projects. They’re rarely about efficiency. They’re about that tiny dopamine hit when your environment just works the way you want. Threw it on GitHub for anyone else who’s tired of clicking buttons. It’s heavily commented because future me will forget how any of this works. Works on any Fedora system with PipeWire or PulseAudio. Just update the device names for your hardware. What’s the most ridiculous thing you’ve automated to avoid a simple manual task? Please tell me I’m not alone in this madness.The Problem
The Solution: Peak Developer Behavior
# The core logic is beautifully simple
current_hour=
if [ || [; then
target_device="" # Speakers
else
target_device="" # Headphones
fi
The Technical Bits (Because I Went Overboard)
Was It Worth It?
The Code