添加 pulse 音频设备显示名补丁

This commit is contained in:
2022-07-10 11:44:27 +08:00
parent 2ab6f9fcc2
commit 32414b4811
2 changed files with 57 additions and 3 deletions

View File

@@ -11,11 +11,14 @@
#+begin_src sh #+begin_src sh
dir=$(pwd) dir=$(pwd)
# 链接配置 # 链接配置
ln -s "${dir}/rc.lua" ~/.config/awesome/ ln -sf "${dir}/rc.lua" ~/.config/awesome/
# 链接定制快捷键 # 链接定制快捷键
ln -s "${dir}/pravitekeys.lua" ~/.config/awesome/ ln -sf "${dir}/pravitekeys.lua" ~/.config/awesome/
# 链接定制主题 # 链接定制主题
ln -s "${dir}/multicolor-theme.lua" ~/.config/awesome/themes/multicolor/theme-personal.lua ln -sf "${dir}/multicolor-theme.lua" ~/.config/awesome/themes/multicolor/theme-personal.lua
# 给 pulse 组建打补丁,该补丁主要为修正蓝牙耳机显示名称
cd ~/.config/awesome/lain/
git apply "$dir/pulse-audio.diff"
#+end_src #+end_src
* 定制 =multicolor= 主题 * 定制 =multicolor= 主题

51
awesome/pulse-audio.diff Normal file
View File

@@ -0,0 +1,51 @@
diff --git a/widget/pulse.lua b/widget/pulse.lua
index 69f4d70..d485d97 100644
--- a/widget/pulse.lua
+++ b/widget/pulse.lua
@@ -22,14 +22,17 @@ local function factory(args)
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'"
+ 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' -e '/device\\.description/p'"
function pulse.update()
helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() },
function(s)
+ local description = string.match(s, "device.description = \"(.-)\"")
+ local devicestring = string.match(s, "device.string = \"(%S+)\"")
+ local device = string.len(description) < string.len(devicestring) and description or devicestring
volume_now = {
index = string.match(s, "index: (%S+)") or "N/A",
- device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
+ device = device or "N/A",
muted = string.match(s, "muted: (%S+)") or "N/A"
}
diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua
index 19e73b9..b1dbc1c 100644
--- a/widget/pulsebar.lua
+++ b/widget/pulsebar.lua
@@ -51,7 +51,7 @@ local function factory(args)
pulsebar.followtag = args.followtag or false
pulsebar.notification_preset = args.notification_preset
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'"
+ 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' -e '/device\\.description/p'"
if not pulsebar.notification_preset then
pulsebar.notification_preset = {
@@ -76,9 +76,12 @@ local function factory(args)
function pulsebar.update(callback)
helpers.async({ awful.util.shell, "-c", type(pulsebar.cmd) == "string" and pulsebar.cmd or pulsebar.cmd() },
function(s)
+ local description = string.match(s, "device.description = \"(.-)\"")
+ local devicestring = string.match(s, "device.string = \"(%S+)\"")
+ local device = string.len(description) < string.len(devicestring) and description or devicestring
volume_now = {
index = string.match(s, "index: (%S+)") or "N/A",
- device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
+ device = device or "N/A",
muted = string.match(s, "muted: (%S+)") or "N/A"
}