add keybindings for ALSA volume control.

This commit is contained in:
2018-06-17 13:26:10 +08:00
parent 7cb603fc99
commit 175249b0a6

View File

@@ -1,4 +1,5 @@
local awful = require("awful"); local awful = require("awful");
local beautiful = require("beautiful")
local altkey = "Mod1" local altkey = "Mod1"
local modkey = "Mod4" local modkey = "Mod4"
@@ -11,6 +12,7 @@ end
pravitekeys = awful.util.table.join( pravitekeys = awful.util.table.join(
-- if app is running, raise it, otherwise launch it
awful.key({ altkey, "Control" }, "a", awful.key({ altkey, "Control" }, "a",
function () function ()
run_or_raise("android-studio", {class = "jetbrains-studio"}) run_or_raise("android-studio", {class = "jetbrains-studio"})
@@ -22,23 +24,57 @@ pravitekeys = awful.util.table.join(
end), end),
awful.key({ altkey, "Control" }, "v", awful.key({ altkey, "Control" }, "v",
function () function ()
run_or_raise("VirtualBox", {class = "VirtualBox"}) run_or_raise("VirtualBox", {class = "VirtualBox"})
end), end),
awful.key({ altkey, "Control" }, "r", awful.key({ altkey, "Control" }, "r",
function () function ()
run_or_raise("urxvtc", {class = "URxvt"}) run_or_raise("urxvtc", {class = "URxvt"})
end), end),
awful.key({ altkey, "Control" }, "e", awful.key({ altkey, "Control" }, "e",
function () function ()
run_or_raise("emacs", {class = "Emacs"}) run_or_raise("emacs", {class = "Emacs"})
end), end),
awful.key({ altkey, "Shift" }, "e", awful.key({ altkey, "Shift" }, "e",
function () function ()
run_or_raise("pcmanfm", {class = "Pcmanfm"}) run_or_raise("pcmanfm", {class = "Pcmanfm"})
end),
-- ALSA volume control
awful.key({ }, "XF86AudioRaiseVolume",
function ()
os.execute(string.format("amixer set %s 1%%+", beautiful.volume.channel))
beautiful.volume.update()
end),
awful.key({ altkey }, "Up",
function ()
os.execute(string.format("amixer set %s 1%%+", beautiful.volume.channel))
beautiful.volume.update()
end),
awful.key({ }, "XF86AudioLowerVolume",
function ()
os.execute(string.format("amixer set %s 1%%-", beautiful.volume.channel))
beautiful.volume.update()
end),
awful.key({ altkey }, "Down",
function ()
os.execute(string.format("amixer set %s 1%%-", beautiful.volume.channel))
beautiful.volume.update()
end),
awful.key({ }, "XF86AudioMute",
function ()
os.execute(string.format("amixer set %s toggle", beautiful.volume.togglechannel
or beautiful.volume.channel))
beautiful.volume.update()
end),
awful.key({ altkey }, "m",
function ()
os.execute(string.format("amixer set %s toggle", beautiful.volume.togglechannel
or beautiful.volume.channel))
beautiful.volume.update()
end) end)
) )