diff options
Diffstat (limited to 'experiments/volume/volume.lua')
-rw-r--r-- | experiments/volume/volume.lua | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/experiments/volume/volume.lua b/experiments/volume/volume.lua index ae7605e..9110a45 100644 --- a/experiments/volume/volume.lua +++ b/experiments/volume/volume.lua @@ -14,8 +14,6 @@ local gears = require("gears") local beautiful = require("beautiful") local watch = require("awful.widget.watch") local utils = require("awesome-wm-widgets.experiments.volume.utils") -local arc_widget = require("awesome-wm-widgets.experiments.volume.arc-widget") -local icon_and_text_widget = require("awesome-wm-widgets.experiments.volume.icon-and-text-widget") local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]] @@ -25,6 +23,12 @@ local DEC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%-' local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle' +local widget_types = { + icon_and_text = require("awesome-wm-widgets.experiments.volume.widgets.icon-and-text-widget"), + icon = require("awesome-wm-widgets.experiments.volume.widgets.icon-widget"), + arc = require("awesome-wm-widgets.experiments.volume.widgets.arc-widget") +} + local volume_widget = wibox.widget{} local rows = { layout = wibox.layout.fixed.vertical } @@ -43,7 +47,7 @@ local popup = awful.popup{ local function build_main_line(device) if device.active_port ~= nil and device.ports[device.active_port] ~= nil then - return device.properties.device_description .. ' - ' .. device.ports[device.active_port] + return device.properties.device_description .. ' ยท ' .. device.ports[device.active_port] else return device.properties.device_description end @@ -90,13 +94,35 @@ local function build_rows(devices, on_checkbox_click, device_type) spacing = 8, layout = wibox.layout.align.horizontal }, - margins = 8, + margins = 4, layout = wibox.container.margin }, bg = beautiful.bg_normal, widget = wibox.container.background } + row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end) + row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end) + + local old_cursor, old_wibox + row:connect_signal("mouse::enter", function(c) + local wb = mouse.current_wibox + old_cursor, old_wibox = wb.cursor, wb + wb.cursor = "hand1" + end) + row:connect_signal("mouse::leave", function(c) + if old_wibox then + old_wibox.cursor = old_cursor + old_wibox = nil + end + end) + + row:connect_signal("button::press", function(c) + spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function() + on_checkbox_click() + end) + end) + table.insert(device_rows, row) end @@ -134,8 +160,15 @@ end local function worker(args) - volume_widget = arc_widget.get_widget() - -- volume_widget = icon_and_text_widget.get_widget() + local args = args or {} + + local widget_type = args.widget_type + + if widget_types[widget_type] == nil then + volume_widget = widget_types['icon_and_text'].get_widget() + else + volume_widget = widget_types[widget_type].get_widget() + end volume_widget:buttons( awful.util.table.join( |