Skip to content

Commit

Permalink
pulseaudio -> pulse; scallback merged into cmd (read wiki)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Bonham committed Oct 5, 2017
1 parent c2b1864 commit b14a2c8
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
34 changes: 23 additions & 11 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand All @@ -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
4 changes: 2 additions & 2 deletions lain-git.rockspec
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/dfs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion util/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
59 changes: 59 additions & 0 deletions widget/pulse.lua
Original file line number Diff line number Diff line change
@@ -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
63 changes: 0 additions & 63 deletions widget/pulseaudio.lua

This file was deleted.

30 changes: 13 additions & 17 deletions widget/pulsebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -30,6 +30,7 @@ local function factory(args)

_current_level = 0,
_mute = "no",
device = "N/A"
}

local args = args or {}
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from c221a2 to 8b9791

0 comments on commit b14a2c8

Please sign in to comment.