简体   繁体   中英

Global hotkeys for next track in awesome wm

How do you deal with function keyboard and with keys:

XF86AudioPlay
XF86AudioPause
XF86AudioPrev
XF86AudioNext 

in awesome wm? I've made shortcuts to raise/lower/mute using the volume buttons in rc.lua

   awful.key({ }, "XF86AudioRaiseVolume", function ()
   awful.util.spawn("amixer set Master 9%+", false) end),
   awful.key({ }, "XF86AudioLowerVolume", function ()
   awful.util.spawn("amixer set Master 9%-", false) end),
   awful.key({ }, "XF86AudioMute", function ()
   awful.util.spawn("amixer set Master toggle", false) end),

I don't have any idea how to the same with Next/Prev/Play buttons. How do you deal with it? I want to use these keys for banshee/spotify.

Ok i hacked this with using dbus ( https://wiki.archlinux.org/index.php/Spotify#D-Bus )

   awful.key({ }, "XF86AudioPlay", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause", false) end),
   awful.key({ }, "XF86AudioNext", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next", false) end),
   awful.key({ }, "XF86AudioPrev", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous", false) end),
   awful.key({ }, "XF86AudioStop", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop", false) end),

I two used dbus for it, I made a sh script for making the controls smart

  • Only 1 player can play at the same time, all the others go on pause
  • of no player on my favorite uri starts in a player I defined
  • players have a chosen priority for the play button

here is my script, maybe you can use it: mediakeys.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM