From 32414b48111b1de134c29f5d439f333bbd6c7b0c Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sun, 10 Jul 2022 11:44:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20pulse=20=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=98=BE=E7=A4=BA=E5=90=8D=E8=A1=A5=E4=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- awesome/README.org | 9 ++++--- awesome/pulse-audio.diff | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 awesome/pulse-audio.diff diff --git a/awesome/README.org b/awesome/README.org index af7cdfd..6f8a800 100644 --- a/awesome/README.org +++ b/awesome/README.org @@ -11,11 +11,14 @@ #+begin_src sh 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 * 定制 =multicolor= 主题 diff --git a/awesome/pulse-audio.diff b/awesome/pulse-audio.diff new file mode 100644 index 0000000..6d2240b --- /dev/null +++ b/awesome/pulse-audio.diff @@ -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" + } +