Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Volume indicator pa
- volumecfg = {}
- volumecfg.sink = " alsa_output.pci-0000_00_1b.0.analog-stereo"
- volumecfg.widget = widget( { type = "textbox", name = "volumecfg.widget", align = "right" } )
- volumecfg.mixercommand = function (command)
- closeLastNoti()
- local fd = io.popen(command .. " && pacmd dump |grep -e set-sink-volume -e set-sink-mute")
- local status = fd:read("*all")
- fd:close()
- local volume = string.match(status, "(0x%x%x%x?%x)")
- volume_f = tonumber(string.format("%04x", volume),"16")
- volume = math.ceil(volume_f/655)
- if string.find(status, " no", 1, true) then
- volume = "<span color='#4E99E6'>♫</span>" .. volume .. "% "
- else
- volume = "♩" .. volume .. "m"
- end
- volumecfg.widget.text = volume
- naughty.notify({font = "Droid Sans 36", position = "bottom_right", screen = screen.count(), border_width = 0, timeout = 2, hover_timeout = 1, title = "Громкость", text = volumecfg.widget.text })
- end
- volumecfg.update = function ()
- volumecfg.mixercommand("pactl set-sink-volume " .. volumecfg.sink .. " +0")
- end
- volumecfg.up = function ()
- local add_volume = " +1000"
- if (volume_f+1000)> 65535 then add_volume = " 65500" end
- volumecfg.mixercommand("pactl set-sink-volume " .. volumecfg.sink .. add_volume)
- end
- volumecfg.down = function ()
- volumecfg.mixercommand("pactl set-sink-volume " .. volumecfg.sink .. " -1000")
- end
- volumecfg.toggle = function ()
- volumecfg.mixercommand("pactl set-sink-mute " .. volumecfg.sink .. " toggle")
- end
- volumecfg.widget:buttons(awful.util.table.join(
- awful.button({ }, 4, function () volumecfg.up() end),
- awful.button({ }, 5, function () volumecfg.down() end),
- awful.button({ }, 3, function () awful.util.spawn("/usr/bin/pavucontrol") end),
- awful.button({ }, 1, function () volumecfg.toggle() end)
- ))
- volumecfg.update()
- volumecfg.widget.border_width = 0
- --volumecfg.widget.width = 80
- volumecfg.widget.border_color = beautiful.fg_focus
- --volumecfg_t = awful.tooltip({ objects = { volumecfg.widget },})
- --volumecfg_t:set_text( "Громкость" )
- --volumecfg_t.border_width = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement