diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-08-23 14:46:17 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-08-23 14:46:17 +0700 |
commit | 668f0c8ff63f1c1728bb72a3aff94b3705539dc7 (patch) | |
tree | e68b38c34c47be5380994cd99351aee2b5cf4ca9 /awesome | |
parent | 19acdd5e805563d019303af48afa84473dca2117 (diff) | |
download | dotfiles-668f0c8ff63f1c1728bb72a3aff94b3705539dc7.tar.gz |
Update 2019-08-23
Diffstat (limited to 'awesome')
-rw-r--r-- | awesome/.config/awesome/rc.lua | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/awesome/.config/awesome/rc.lua b/awesome/.config/awesome/rc.lua index 5f4ad36..b58a6a7 100644 --- a/awesome/.config/awesome/rc.lua +++ b/awesome/.config/awesome/rc.lua @@ -182,15 +182,21 @@ mybattery:buttons(awful.util.table.join( -- Create a volume widget local myvolume_text = wibox.widget.textbox() vicious.register(myvolume_text, - function (format, warg) - local f = io.popen("pulsemixer --get-volume --get-mute") - left, right, mute = f:read("*number", "*number", "*number") - f:close() - return {left, right, mute} - end, + {async = function (format, warg, callback) + awful.spawn.easy_async( + "pulsemixer --get-volume --get-mute", + function (stdout) + local volume = {} + for m in stdout:gmatch"(%d+)" do + table.insert(volume, tonumber(m)) + end + callback(volume) + end) + end}, function (widget, args) - return (" %s%03d%%"):format(args[3] == 0 and '🔉' or '🔈', - (args[1] + args[2]) / 2) + return (" %s%03d%%"):format( + args[3] == 0 and '🔉' or '🔈', + math.floor((args[1] + args[2] + 1) / 2)) end, 1) local function volume_setter(parameter) |