mirror of https://github.com/lcpz/lain.git
pulseaudio -> pulse; scallback merged into cmd (read wiki)
This commit is contained in:
parent
c2b186467c
commit
055e663772
|
@ -1,3 +1,3 @@
|
|||
[submodule "lain.wiki"]
|
||||
path = wiki
|
||||
url = https://github.com/copycat-killer/lain.wiki.git
|
||||
url = https://github.com/lcpz/lain.wiki.git
|
||||
|
|
|
@ -1,21 +1,33 @@
|
|||
# If you have a question
|
||||
# Please, read me!
|
||||
|
||||
Take the following steps:
|
||||
|
||||
1. [Google it](https://encrypted.google.com)
|
||||
2. Search [Awesome doc](https://awesomewm.org/doc)
|
||||
3. Ask [community](https://awesomewm.org/community)
|
||||
|
||||
and, if you still don't have an answer, you can ask here.
|
||||
|
||||
**Please be warned:** if your question is __unrelated__ to this repository, a reply is only an act of kindness.
|
||||
So that I can help you quickly and without having to redirect you here.
|
||||
|
||||
# If you have an issue
|
||||
|
||||
**Please read the [wiki](https://github.com/copycat-killer/lain/wiki) and search the [Issues section](https://github.com/copycat-killer/lain/issues) first.**
|
||||
**Please read the [wiki](https://github.com/lcpz/lain/wiki) and search the [Issues section](https://github.com/lcpz/lain/issues) first.**
|
||||
|
||||
If you can't find a solution there, then go ahead and provide:
|
||||
|
||||
* output of `awesome -v` and `lua -v`
|
||||
* expected behavior and actual behavior
|
||||
* steps to reproduce the problem
|
||||
* X error log
|
||||
|
||||
# How to provide X error log
|
||||
|
||||
There are two ways:
|
||||
|
||||
* (Physically) Restart X like this:
|
||||
```shell
|
||||
startx -- -keeptty -nolisten tcp > $HOME/.xorg.log 2>&1
|
||||
```
|
||||
the error log will be output into `$HOME/.xorg.log`.
|
||||
|
||||
* (Virtually) Use [Xephyr](https://wikipedia.org/wiki/Xephyr):
|
||||
```shell
|
||||
# set screen size as you like
|
||||
Xephyr :1 -screen 1280x800 2> stdout.txt & DISPLAY=:1 awesome
|
||||
```
|
||||
the error log will be output in the file `stdout.txt`.
|
||||
|
||||
Before reporting, read the log and see if you can solve it yourself.
|
||||
|
|
|
@ -5,10 +5,10 @@ Lain
|
|||
Layouts, widgets and utilities for Awesome WM 4.x
|
||||
-------------------------------------------------
|
||||
|
||||
:Author: Luke Bonham <dada [at] archlinux [dot] info>
|
||||
:Author: Luca CPZ <dada [at] archlinux [dot] info>
|
||||
:Version: git
|
||||
:License: GNU-GPL2_
|
||||
:Source: https://github.com/copycat-killer/lain
|
||||
:Source: https://github.com/lcpz/lain
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
@ -35,5 +35,5 @@ Contributed widgets have to be put in ``widget/contrib``.
|
|||
.. _GNU-GPL2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
.. _awesome-vain: https://github.com/vain/awesome-vain
|
||||
.. _Awesome: https://github.com/awesomeWM/awesome
|
||||
.. _wiki: https://github.com/copycat-killer/lain/wiki
|
||||
.. _lain.helpers: https://github.com/copycat-killer/lain/blob/master/helpers.lua
|
||||
.. _wiki: https://github.com/lcpz/lain/wiki
|
||||
.. _lain.helpers: https://github.com/lcpz/lain/blob/master/helpers.lua
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package = "lain"
|
||||
version = "git"
|
||||
source = {
|
||||
url = "https://github.com/copycat-killer/lain",
|
||||
url = "https://github.com/lcpz/lain",
|
||||
tag = "git"
|
||||
}
|
||||
description = {
|
||||
|
@ -11,7 +11,7 @@ description = {
|
|||
|
||||
Optional dependency: curl (for IMAP, MPD and weather widgets).
|
||||
]],
|
||||
homepage = "https://github.com/copycat-killer/lain",
|
||||
homepage = "https://github.com/lcpz/lain",
|
||||
license = "GPL v2"
|
||||
}
|
||||
dependencies = {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# JM, 10/12/2004
|
||||
#
|
||||
# Integrated into Lain in september 2013
|
||||
# https://github.com/copycat-killer/lain
|
||||
# https://github.com/lcpz/lain
|
||||
|
||||
# Requires gawk
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ function util.magnify_client(c, width_f, height_f)
|
|||
end
|
||||
end
|
||||
|
||||
-- https://github.com/copycat-killer/lain/issues/195
|
||||
-- https://github.com/lcpz/lain/issues/195
|
||||
function util.mc(c, width_f, height_f)
|
||||
c = c or util.magnified_client
|
||||
if not c then return end
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
--[[
|
||||
|
||||
Licensed under GNU General Public License v2
|
||||
* (c) 2016, Luke Bonham
|
||||
|
||||
--]]
|
||||
|
||||
local helpers = require("lain.helpers")
|
||||
local shell = require("awful.util").shell
|
||||
local wibox = require("wibox")
|
||||
local string = { gmatch = string.gmatch,
|
||||
match = string.match,
|
||||
format = string.format }
|
||||
local type = type
|
||||
|
||||
-- PulseAudio volume
|
||||
-- lain.widget.pulse
|
||||
|
||||
local function factory(args)
|
||||
local pulse = { widget = wibox.widget.textbox(), device = "N/A" }
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 5
|
||||
local settings = args.settings or function() end
|
||||
|
||||
pulse.devicetype = args.devicetype or "sink"
|
||||
pulse.cmd = args.cmd or "pacmd list-" .. pulse.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
|
||||
|
||||
function pulse.update()
|
||||
helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() },
|
||||
function(s)
|
||||
volume_now = {
|
||||
index = string.match(s, "index: (%S+)") or "N/A",
|
||||
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
|
||||
muted = string.match(s, "muted: (%S+)") or "N/A"
|
||||
}
|
||||
|
||||
pulse.device = volume_now.index
|
||||
|
||||
local ch = 1
|
||||
volume_now.channel = {}
|
||||
for v in string.gmatch(s, ":.-(%d+)%%") do
|
||||
volume_now.channel[ch] = v
|
||||
ch = ch + 1
|
||||
end
|
||||
|
||||
volume_now.left = volume_now.channel[1] or "N/A"
|
||||
volume_now.right = volume_now.channel[2] or "N/A"
|
||||
|
||||
widget = pulse.widget
|
||||
settings()
|
||||
end)
|
||||
end
|
||||
|
||||
helpers.newtimer("pulse", timeout, pulse.update)
|
||||
|
||||
return pulse
|
||||
end
|
||||
|
||||
return factory
|
|
@ -1,63 +0,0 @@
|
|||
--[[
|
||||
|
||||
Licensed under GNU General Public License v2
|
||||
* (c) 2016, Luke Bonham
|
||||
|
||||
--]]
|
||||
|
||||
local helpers = require("lain.helpers")
|
||||
local shell = require("awful.util").shell
|
||||
local wibox = require("wibox")
|
||||
local string = { gmatch = string.gmatch,
|
||||
match = string.match,
|
||||
format = string.format }
|
||||
|
||||
-- PulseAudio volume
|
||||
-- lain.widget.pulseaudio
|
||||
|
||||
local function factory(args)
|
||||
local pulseaudio = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 5
|
||||
local settings = args.settings or function() end
|
||||
local scallback = args.scallback
|
||||
|
||||
pulseaudio.device = "N/A"
|
||||
pulseaudio.devicetype = args.devicetype or "sink"
|
||||
pulseaudio.cmd = args.cmd or "pacmd list-" .. pulseaudio.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
|
||||
|
||||
function pulseaudio.update()
|
||||
if scallback then pulseaudio.cmd = scallback() end
|
||||
|
||||
helpers.async({ shell, "-c", pulseaudio.cmd }, function(s)
|
||||
volume_now = {
|
||||
index = string.match(s, "index: (%S+)") or "N/A",
|
||||
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
|
||||
sink = device, -- legacy API
|
||||
muted = string.match(s, "muted: (%S+)") or "N/A"
|
||||
}
|
||||
|
||||
pulseaudio.device = volume_now.index
|
||||
|
||||
local ch = 1
|
||||
volume_now.channel = {}
|
||||
for v in string.gmatch(s, ":.-(%d+)%%") do
|
||||
volume_now.channel[ch] = v
|
||||
ch = ch + 1
|
||||
end
|
||||
|
||||
volume_now.left = volume_now.channel[1] or "N/A"
|
||||
volume_now.right = volume_now.channel[2] or "N/A"
|
||||
|
||||
widget = pulseaudio.widget
|
||||
|
||||
settings()
|
||||
end)
|
||||
end
|
||||
|
||||
helpers.newtimer("pulseaudio", timeout, pulseaudio.update)
|
||||
|
||||
return pulseaudio
|
||||
end
|
||||
|
||||
return factory
|
|
@ -17,7 +17,7 @@ local string = { format = string.format,
|
|||
rep = string.rep }
|
||||
local type, tonumber = type, tonumber
|
||||
|
||||
-- Pulseaudio volume bar
|
||||
-- PulseAudio volume bar
|
||||
-- lain.widget.pulsebar
|
||||
|
||||
local function factory(args)
|
||||
|
@ -30,6 +30,7 @@ local function factory(args)
|
|||
|
||||
_current_level = 0,
|
||||
_mute = "no",
|
||||
device = "N/A"
|
||||
}
|
||||
|
||||
local args = args or {}
|
||||
|
@ -39,20 +40,17 @@ local function factory(args)
|
|||
local height = args.heigth or 1
|
||||
local ticks = args.ticks or false
|
||||
local ticks_size = args.ticks_size or 7
|
||||
local scallback = args.scallback
|
||||
|
||||
pulsebar.cmd = args.cmd or "pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
|
||||
pulsebar.sink = args.sink or 0 -- Legacy, does nothing
|
||||
pulsebar.colors = args.colors or pulsebar.colors
|
||||
pulsebar.followtag = args.followtag or false
|
||||
pulsebar.notification_preset = args.notification_preset
|
||||
pulsebar.device = "N/A"
|
||||
pulsebar.devicetype = args.devicetype or "sink"
|
||||
pulsebar.cmd = args.cmd or "pacmd list-" .. pulsebar.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
|
||||
|
||||
if not pulsebar.notification_preset then
|
||||
pulsebar.notification_preset = {}
|
||||
pulsebar.notification_preset.font = "Monospace 10"
|
||||
pulsebar.notification_preset = {
|
||||
font = "Monospace 10"
|
||||
}
|
||||
end
|
||||
|
||||
pulsebar.bar = wibox.widget {
|
||||
|
@ -70,14 +68,12 @@ local function factory(args)
|
|||
pulsebar.tooltip = awful.tooltip({ objects = { pulsebar.bar } })
|
||||
|
||||
function pulsebar.update(callback)
|
||||
if scallback then pulsebar.cmd = scallback() end
|
||||
|
||||
helpers.async({ awful.util.shell, "-c", pulsebar.cmd }, function(s)
|
||||
helpers.async({ awful.util.shell, "-c", type(pulsebar.cmd) == "string" and pulsebar.cmd or pulsebar.cmd() },
|
||||
function(s)
|
||||
volume_now = {
|
||||
index = string.match(s, "index: (%S+)") or "N/A",
|
||||
index = string.match(s, "index: (%S+)") or "N/A",
|
||||
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
|
||||
sink = device, -- legacy API
|
||||
muted = string.match(s, "muted: (%S+)") or "N/A"
|
||||
muted = string.match(s, "muted: (%S+)") or "N/A"
|
||||
}
|
||||
|
||||
pulsebar.device = volume_now.index
|
||||
|
@ -102,11 +98,11 @@ local function factory(args)
|
|||
pulsebar.bar:set_value(pulsebar._current_level / 100)
|
||||
if pulsebar._current_level == 0 or mute == "yes" then
|
||||
pulsebar._mute = mute
|
||||
pulsebar.tooltip:set_text ("[Muted]")
|
||||
pulsebar.tooltip:set_text ("[muted]")
|
||||
pulsebar.bar.color = pulsebar.colors.mute
|
||||
else
|
||||
pulsebar._mute = "no"
|
||||
pulsebar.tooltip:set_text(string.format("%s: %s", pulsebar.device, volu))
|
||||
pulsebar.tooltip:set_text(string.format("%s %s: %s", pulsebar.devicetype, pulsebar.device, volu))
|
||||
pulsebar.bar.color = pulsebar.colors.unmute
|
||||
end
|
||||
|
||||
|
@ -121,10 +117,10 @@ local function factory(args)
|
|||
pulsebar.update(function()
|
||||
local preset = pulsebar.notification_preset
|
||||
|
||||
preset.title = string.format("Sink %s - %s%%", pulsebar.device, pulsebar._current_level)
|
||||
preset.title = string.format("%s %s - %s%%", pulsebar.devicetype, pulsebar.device, pulsebar._current_level)
|
||||
|
||||
if pulsebar._mute == "yes" then
|
||||
preset.title = preset.title .. " Muted"
|
||||
preset.title = preset.title .. " muted"
|
||||
end
|
||||
|
||||
int = math.modf((pulsebar._current_level / 100) * awful.screen.focused().mywibox.height)
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit c221a2725d3968f85615328252b710fe0e60bd9e
|
||||
Subproject commit d9029707520bf9ce8e3f695659d8ceea4fef0f01
|
Loading…
Reference in New Issue