audio volume compat pulseaudio and alsa
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
local lain = require("lain")
|
local lain = require("lain")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local volume = lain.widget.pulse()
|
|
||||||
local altkey = "Mod1"
|
local altkey = "Mod1"
|
||||||
local modkey = "Mod4"
|
local modkey = "Mod4"
|
||||||
|
local use_pulse = true
|
||||||
|
|
||||||
function run_or_raise (cmd, rule)
|
function run_or_raise (cmd, rule)
|
||||||
local matcher = function (c)
|
local matcher = function (c)
|
||||||
@@ -12,6 +12,29 @@ function run_or_raise (cmd, rule)
|
|||||||
awful.client.run_or_raise(cmd, matcher)
|
awful.client.run_or_raise(cmd, matcher)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local volume_raise, volume_lower, volume_mute;
|
||||||
|
|
||||||
|
if use_pulse then
|
||||||
|
volume_raise = function()
|
||||||
|
os.execute(string.format("pactl set-sink-volume %s +1%%", beautiful.volume.device))
|
||||||
|
end
|
||||||
|
volume_lower = function()
|
||||||
|
os.execute(string.format("pactl set-sink-volume %s -1%%", beautiful.volume.device))
|
||||||
|
end
|
||||||
|
volume_mute = function()
|
||||||
|
os.execute(string.format("pactl set-sink-mute %s toggle", beautiful.volume.device))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
volume_raise = function()
|
||||||
|
os.execute(string.format("amixer -q set %s 1%%+", beautiful.volume.channel))
|
||||||
|
end
|
||||||
|
volume_lower = function()
|
||||||
|
os.execute(string.format("amixer -q set %s 1%%-", beautiful.volume.channel))
|
||||||
|
end
|
||||||
|
volume_mute = function()
|
||||||
|
os.execute(string.format("amixer -q set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
pravitekeys = awful.util.table.join(
|
pravitekeys = awful.util.table.join(
|
||||||
-- if app is running, raise it, otherwise launch it
|
-- if app is running, raise it, otherwise launch it
|
||||||
@@ -60,38 +83,32 @@ pravitekeys = awful.util.table.join(
|
|||||||
-- PulseAudio volume control
|
-- PulseAudio volume control
|
||||||
awful.key({ }, "XF86AudioRaiseVolume",
|
awful.key({ }, "XF86AudioRaiseVolume",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-volume %s +1%%", volume.device))
|
volume_raise()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey }, "Up",
|
awful.key({ modkey }, "Up",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-volume %s +1%%", volume.device))
|
volume_raise()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ }, "XF86AudioLowerVolume",
|
awful.key({ }, "XF86AudioLowerVolume",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-volume %s -1%%", volume.device))
|
volume_lower()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey }, "Down",
|
awful.key({ modkey }, "Down",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-volume %s -1%%", volume.device))
|
volume_lower()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ }, "XF86AudioMute",
|
awful.key({ }, "XF86AudioMute",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-mute %s toggle", volume.device))
|
volume_mute()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Shift" }, "m",
|
awful.key({ modkey, "Shift" }, "m",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("pactl set-sink-mute %s toggle", volume.device))
|
volume_mute()
|
||||||
volume.update()
|
|
||||||
beautiful.volume.update()
|
beautiful.volume.update()
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user