Print file names with duration for musicbrainz.org with this elegant one-liner:
for i in *mp3 ; \ do dur=$(ffprobe "$i" 2>&1 | \ grep Duration | \ perl -ne '/Duration: 00:(.*?)\./; print $1;'); \ echo "${i%%.mp3} $dur"; \ done
Print file names with duration for musicbrainz.org with this elegant one-liner:
for i in *mp3 ; \ do dur=$(ffprobe "$i" 2>&1 | \ grep Duration | \ perl -ne '/Duration: 00:(.*?)\./; print $1;'); \ echo "${i%%.mp3} $dur"; \ done
This definitely merits a post. While working on my Qt Audio Player (BeetPlayer), I wanted control it via the Media Keys of my Keyboard. Since I’m using KDE on Linux, I quickly found out about KGlobalAccel.
Unfortunately, there’s no decent documentation available. The API docs are kinda useless, and there’s no tutorial available, at least not with my Google foo, so here is how it works:
First and foremost, set QObject::objectName() for the QAction you want to register. It should be unique!
Don’t forget to change your CMake file or your .pro-File if you’re using qmake.
Then register a shortcut with KGlobalAccel::self()->setShortcut() like this:
QAction *muteA = new QAction(QIcon(":/mute.png"), tr("Mute"), this); muteA->setObjectName("beetPlayerMute"); connect(muteA, SIGNAL(triggered(bool)), this, SLOT(mute(bool))); KGlobalAccel::self()->setShortcut(muteA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeMute), KGlobalAccel ::Autoloading);
After that launch KDE System Settings->Shortcuts->Global Shortcuts. There should be an entry for your Application. Select it and set the shortcut. Haven’t figured out how a default shortcut, but it doesn’t really matter when it shows up there.