Tasty Linux One-Liners

Non-eopkg stuff should work on any distro, but Solus is what I use. It cured me of distrohopping and let me give up Windows for good.

It still counts as a one-liner even if I add line breaks for readability okay.


Translate selection and show as a notification

xclip -o | trans -b  | xargs -0 notify-send

I have this bound to Super+W. Requires translate-shell.


List eopkg packages sorted by size

eopkg li -l |
awk '/Name:/ {sub(/,$/,"",$2); name= $2} /Installed Size:/ {print $5$6, name}' |
sort -h

Good for when you’re running out of disk space.


Show a notification when a device joins your LAN

sudo tcpdump -l broadcast |
stdbuf -o0 awk  '/Broadcast Null Unnumbered,/ { print $2 }'  |
while read line; do echo "$line"; notify-send "New device on LAN" "$line"; done

Detects DHCPDISCOVER messages, as they’re broadcast to all devices. Useful for knowing when your roommate gets home :D


Paste into KDE Connect

kdeconnect-cli -n motorola --share "$(xclip -selection c -o)"

Replace motorola with your device’s name.
If you copy a file in your file manager, it will transfer that file, but if it’s a URL it will open it on your phone!


 curl -s $(xclip -o -selection c) | pup '[itemprop=name] text{}' |
 jq -s -R -r @uri |
 parallel "curl -s -H \"Authorization: Bearer $(curl https://open.spotify.com/access_token\?reason\=transport\&productType\=web_player -s |
 jq -r .accessToken)\" https:/api.spotify.com/v1/search\?q\={}\&type=album,artist,track" |
 jq '.. | .spotify? | select(. != null)' -r |
 tail -n 1

Turns a link in your clipboard like https://play.google.com/music/m/T5ngi6cvjdhkcwdfqhjto6i4l4i and turns it into one like https://open.spotify.com/track/0592SR3kJL33sOtMjgWBgw, getting a token automatically.

Basically I’m the only one who has a GPM subscription out of all my friends so I need this to share songs with them.

Requires pup for HTML parsing and jq for JSON parsing. And gnu parallel because it’s a better xargs.