Skip to content

Commit 055e663

Browse files
author
Luke Bonham
committed
pulseaudio -> pulse; scallback merged into cmd (read wiki)
1 parent c2b1864 commit 055e663

File tree

10 files changed

+105
-101
lines changed

10 files changed

+105
-101
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "lain.wiki"]
22
path = wiki
3-
url = https://github.com/copycat-killer/lain.wiki.git
3+
url = https://github.com/lcpz/lain.wiki.git

ISSUE_TEMPLATE.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1-
# If you have a question
1+
# Please, read me!
22

3-
Take the following steps:
4-
5-
1. [Google it](https://encrypted.google.com)
6-
2. Search [Awesome doc](https://awesomewm.org/doc)
7-
3. Ask [community](https://awesomewm.org/community)
8-
9-
and, if you still don't have an answer, you can ask here.
10-
11-
**Please be warned:** if your question is __unrelated__ to this repository, a reply is only an act of kindness.
3+
So that I can help you quickly and without having to redirect you here.
124

135
# If you have an issue
146

15-
**Please read the [wiki](https://github.com/copycat-killer/lain/wiki) and search the [Issues section](https://github.com/copycat-killer/lain/issues) first.**
7+
**Please read the [wiki](https://github.com/lcpz/lain/wiki) and search the [Issues section](https://github.com/lcpz/lain/issues) first.**
168

179
If you can't find a solution there, then go ahead and provide:
1810

1911
* output of `awesome -v` and `lua -v`
2012
* expected behavior and actual behavior
2113
* steps to reproduce the problem
14+
* X error log
15+
16+
# How to provide X error log
17+
18+
There are two ways:
19+
20+
* (Physically) Restart X like this:
21+
```shell
22+
startx -- -keeptty -nolisten tcp > $HOME/.xorg.log 2>&1
23+
```
24+
the error log will be output into `$HOME/.xorg.log`.
25+
26+
* (Virtually) Use [Xephyr](https://wikipedia.org/wiki/Xephyr):
27+
```shell
28+
# set screen size as you like
29+
Xephyr :1 -screen 1280x800 2> stdout.txt & DISPLAY=:1 awesome
30+
```
31+
the error log will be output in the file `stdout.txt`.
32+
33+
Before reporting, read the log and see if you can solve it yourself.

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Lain
55
Layouts, widgets and utilities for Awesome WM 4.x
66
-------------------------------------------------
77

8-
:Author: Luke Bonham <dada [at] archlinux [dot] info>
8+
:Author: Luca CPZ <dada [at] archlinux [dot] info>
99
:Version: git
1010
:License: GNU-GPL2_
11-
:Source: https://github.com/copycat-killer/lain
11+
:Source: https://github.com/lcpz/lain
1212

1313
Description
1414
-----------
@@ -35,5 +35,5 @@ Contributed widgets have to be put in ``widget/contrib``.
3535
.. _GNU-GPL2: http://www.gnu.org/licenses/gpl-2.0.html
3636
.. _awesome-vain: https://github.com/vain/awesome-vain
3737
.. _Awesome: https://github.com/awesomeWM/awesome
38-
.. _wiki: https://github.com/copycat-killer/lain/wiki
39-
.. _lain.helpers: https://github.com/copycat-killer/lain/blob/master/helpers.lua
38+
.. _wiki: https://github.com/lcpz/lain/wiki
39+
.. _lain.helpers: https://github.com/lcpz/lain/blob/master/helpers.lua

lain-git.rockspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package = "lain"
22
version = "git"
33
source = {
4-
url = "https://github.com/copycat-killer/lain",
4+
url = "https://github.com/lcpz/lain",
55
tag = "git"
66
}
77
description = {
@@ -11,7 +11,7 @@ description = {
1111
1212
Optional dependency: curl (for IMAP, MPD and weather widgets).
1313
]],
14-
homepage = "https://github.com/copycat-killer/lain",
14+
homepage = "https://github.com/lcpz/lain",
1515
license = "GPL v2"
1616
}
1717
dependencies = {

scripts/dfs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# JM, 10/12/2004
55
#
66
# Integrated into Lain in september 2013
7-
# https://github.com/copycat-killer/lain
7+
# https://github.com/lcpz/lain
88

99
# Requires gawk
1010

util/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function util.magnify_client(c, width_f, height_f)
7676
end
7777
end
7878

79-
-- https://github.com/copycat-killer/lain/issues/195
79+
-- https://github.com/lcpz/lain/issues/195
8080
function util.mc(c, width_f, height_f)
8181
c = c or util.magnified_client
8282
if not c then return end

widget/pulse.lua

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--[[
2+
3+
Licensed under GNU General Public License v2
4+
* (c) 2016, Luke Bonham
5+
6+
--]]
7+
8+
local helpers = require("lain.helpers")
9+
local shell = require("awful.util").shell
10+
local wibox = require("wibox")
11+
local string = { gmatch = string.gmatch,
12+
match = string.match,
13+
format = string.format }
14+
local type = type
15+
16+
-- PulseAudio volume
17+
-- lain.widget.pulse
18+
19+
local function factory(args)
20+
local pulse = { widget = wibox.widget.textbox(), device = "N/A" }
21+
local args = args or {}
22+
local timeout = args.timeout or 5
23+
local settings = args.settings or function() end
24+
25+
pulse.devicetype = args.devicetype or "sink"
26+
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'"
27+
28+
function pulse.update()
29+
helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() },
30+
function(s)
31+
volume_now = {
32+
index = string.match(s, "index: (%S+)") or "N/A",
33+
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
34+
muted = string.match(s, "muted: (%S+)") or "N/A"
35+
}
36+
37+
pulse.device = volume_now.index
38+
39+
local ch = 1
40+
volume_now.channel = {}
41+
for v in string.gmatch(s, ":.-(%d+)%%") do
42+
volume_now.channel[ch] = v
43+
ch = ch + 1
44+
end
45+
46+
volume_now.left = volume_now.channel[1] or "N/A"
47+
volume_now.right = volume_now.channel[2] or "N/A"
48+
49+
widget = pulse.widget
50+
settings()
51+
end)
52+
end
53+
54+
helpers.newtimer("pulse", timeout, pulse.update)
55+
56+
return pulse
57+
end
58+
59+
return factory

widget/pulseaudio.lua

Lines changed: 0 additions & 63 deletions
This file was deleted.

widget/pulsebar.lua

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local string = { format = string.format,
1717
rep = string.rep }
1818
local type, tonumber = type, tonumber
1919

20-
-- Pulseaudio volume bar
20+
-- PulseAudio volume bar
2121
-- lain.widget.pulsebar
2222

2323
local function factory(args)
@@ -30,6 +30,7 @@ local function factory(args)
3030

3131
_current_level = 0,
3232
_mute = "no",
33+
device = "N/A"
3334
}
3435

3536
local args = args or {}
@@ -39,20 +40,17 @@ local function factory(args)
3940
local height = args.heigth or 1
4041
local ticks = args.ticks or false
4142
local ticks_size = args.ticks_size or 7
42-
local scallback = args.scallback
4343

44-
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'"
45-
pulsebar.sink = args.sink or 0 -- Legacy, does nothing
4644
pulsebar.colors = args.colors or pulsebar.colors
4745
pulsebar.followtag = args.followtag or false
4846
pulsebar.notification_preset = args.notification_preset
49-
pulsebar.device = "N/A"
5047
pulsebar.devicetype = args.devicetype or "sink"
5148
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'"
5249

5350
if not pulsebar.notification_preset then
54-
pulsebar.notification_preset = {}
55-
pulsebar.notification_preset.font = "Monospace 10"
51+
pulsebar.notification_preset = {
52+
font = "Monospace 10"
53+
}
5654
end
5755

5856
pulsebar.bar = wibox.widget {
@@ -70,14 +68,12 @@ local function factory(args)
7068
pulsebar.tooltip = awful.tooltip({ objects = { pulsebar.bar } })
7169

7270
function pulsebar.update(callback)
73-
if scallback then pulsebar.cmd = scallback() end
74-
75-
helpers.async({ awful.util.shell, "-c", pulsebar.cmd }, function(s)
71+
helpers.async({ awful.util.shell, "-c", type(pulsebar.cmd) == "string" and pulsebar.cmd or pulsebar.cmd() },
72+
function(s)
7673
volume_now = {
77-
index = string.match(s, "index: (%S+)") or "N/A",
74+
index = string.match(s, "index: (%S+)") or "N/A",
7875
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
79-
sink = device, -- legacy API
80-
muted = string.match(s, "muted: (%S+)") or "N/A"
76+
muted = string.match(s, "muted: (%S+)") or "N/A"
8177
}
8278

8379
pulsebar.device = volume_now.index
@@ -102,11 +98,11 @@ local function factory(args)
10298
pulsebar.bar:set_value(pulsebar._current_level / 100)
10399
if pulsebar._current_level == 0 or mute == "yes" then
104100
pulsebar._mute = mute
105-
pulsebar.tooltip:set_text ("[Muted]")
101+
pulsebar.tooltip:set_text ("[muted]")
106102
pulsebar.bar.color = pulsebar.colors.mute
107103
else
108104
pulsebar._mute = "no"
109-
pulsebar.tooltip:set_text(string.format("%s: %s", pulsebar.device, volu))
105+
pulsebar.tooltip:set_text(string.format("%s %s: %s", pulsebar.devicetype, pulsebar.device, volu))
110106
pulsebar.bar.color = pulsebar.colors.unmute
111107
end
112108

@@ -121,10 +117,10 @@ local function factory(args)
121117
pulsebar.update(function()
122118
local preset = pulsebar.notification_preset
123119

124-
preset.title = string.format("Sink %s - %s%%", pulsebar.device, pulsebar._current_level)
120+
preset.title = string.format("%s %s - %s%%", pulsebar.devicetype, pulsebar.device, pulsebar._current_level)
125121

126122
if pulsebar._mute == "yes" then
127-
preset.title = preset.title .. " Muted"
123+
preset.title = preset.title .. " muted"
128124
end
129125

130126
int = math.modf((pulsebar._current_level / 100) * awful.screen.focused().mywibox.height)

wiki

Submodule wiki updated from c221a27 to d902970

0 commit comments

Comments
 (0)