Sunday, 29 June 2014

Play all songs whose names match a regular expression.


#!/bin/sh
locate -0i --regex "($*).*\.(mp3|mpe?g|avi|mkv|ogg|au|m4a|flac)$" | xargs -0 nohup vlc >/dev/null 2>&1 &

Replace vlc with the player of your choice, save as /usr/local/bin/lplay, make it executable with 'sudo chmod +x /usr/local/bin/lplay' - et voila, you can do pretty complex music queries without amarok or any other bulky and buggy music player, provided there is enough information in their file names.

Since locale uses its own pre-built file database, this will be much faster than using "find" that actually traverses the entire file system.

Examples:
$ lplay music/j-pop
# play your J-Pop collection
$ lplay '風|wind|kaze'
# play everything that has the word or kanji "wind" in it

$ lplay 'bob.*dylan'
# play all Bob Dylan's songs

P.S.
Alternatviely, you can filter out audio/video files by their headers instead of using their extensions. It will give more refined results (you may be surprised how many games keep video and music in standard formats with non-standard extensions!), but will be slower, especially for general queries that have a lot of hits that are not music/video files.
locate -0i --regex "$*" | xargs -0 file -0 | grep -Eia 'audio|video' | cut -d '' -f1 | xargs -d\\n nohup vlc >/dev/null 2>&1 &

Tuesday, 10 June 2014

Don't show Steam in KDE4 task manager when minimized to tray.

Open /usr/share/applications/steam.desktop and replace line:
Exec=/usr/bin/steam %U
with (for Steam installed from Valve package):
Exec=sh -c "STEAM_FRAME_FORCE_CLOSE=1 /usr/bin/steam %U"
or (for Steam installed from Ubuntu repo):
Exec=sh -c "STEAM_FRAME_FORCE_CLOSE=1 /usr/games/steam %U"

Or just launch it from console as:
$ STEAM_FRAME_FORCE_CLOSE=1 /usr/bin/steam

(solution based on a post from https://github.com/ValveSoftware/steam-for-linux/issues/1025)