diff options
-rw-r--r-- | bar.lua | 73 | ||||
-rw-r--r-- | buttons.lua | 2 | ||||
-rw-r--r-- | func/noborders.lua | 6 | ||||
-rw-r--r-- | func/sloppyfocus.lua | 3 | ||||
-rw-r--r-- | hosts/libreX60.lua | 10 | ||||
-rw-r--r-- | keybindings.lua | 10 | ||||
-rw-r--r-- | layouts.lua | 3 | ||||
-rw-r--r-- | lib/pavolctld.lua | 15 | ||||
-rw-r--r-- | lib/wiboxtooltip.lua | 53 | ||||
-rw-r--r-- | rc.lua | 23 | ||||
-rw-r--r-- | rules.lua | 2 | ||||
-rw-r--r-- | theme.lua | 39 | ||||
-rw-r--r-- | widgets/classiclayouts.lua | 37 | ||||
-rw-r--r-- | widgets/pavolctld.lua | 134 | ||||
-rw-r--r-- | widgets/tasklist.lua | 80 | ||||
-rw-r--r-- | widgets/volumedropdown.lua | 195 |
16 files changed, 456 insertions, 229 deletions
@@ -1,7 +1,7 @@ local awful = require("awful") local wibox = require("wibox") local beautiful = require("beautiful") -local buttons = require("buttons") +require("buttons") -- load widgets --local mylauncher = require("widgets.button") @@ -11,21 +11,19 @@ local widget_temperature = require("widgets.temperature") local widget_battery = require("widgets.battery") local classiclayoutbox = require("widgets.classiclayouts") local volume_control = require("widgets.pavolctld") +local tasklist = require("widgets.tasklist") local widget_volume = volume_control.textbox -- store widgets here -local spacing = 8 -local separator = { widget = wibox.widget.separator, opacity = 0 } - local widgets = { temperature_file = nil; - spacing = spacing, -- constant + spacing = beautiful.margin_leftright, -- constant layoutlist = wibox.widget { layout = wibox.layout.fixed.horizontal, buttons = layout_buttons, wibox.container.margin( classiclayoutbox(s), - spacing, spacing, 0, 0 + beautiful.margin_leftright, beautiful.margin_leftright, 0, 0 ), }, taglist = function(s) return awful.widget.taglist { @@ -33,26 +31,11 @@ local widgets = { filter = awful.widget.taglist.filter.noempty, buttons = taglist_buttons, } end, - tasklist = function(s) return wibox.widget { - layout = wibox.layout.align.horizontal, - expand = "outside", - separator, - awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.focused, - buttons = tasklist_buttons, - widget_template = { - id = "text_role", - widget = wibox.widget.textbox, - align = "center", - }, - }, - separator, - } end, - textclock = { - widget = wibox.widget.textclock, + tasklist = tasklist, + textclock = wibox.widget { format = "%A, %B %-e, %-I:%M %p", font = beautiful.textclock_font, + widget = wibox.widget.textclock, }, cpu = { layout = wibox.layout.fixed.horizontal, @@ -67,7 +50,7 @@ local widgets = { widget_ram_usage, wibox.widget.textbox "%", }, - vol = { + vol = wibox.widget { layout = wibox.layout.fixed.horizontal, buttons = volume_buttons, wibox.widget.textbox "VOL: ", @@ -84,7 +67,7 @@ local widgets = { -- left widget group func function widgets.left_widgets(s) return wibox.widget { layout = wibox.layout.fixed.horizontal, - spacing = spacing, + spacing = beautiful.margin_leftright, { layout = wibox.layout.fixed.horizontal, widgets.layoutlist, @@ -93,7 +76,7 @@ function widgets.left_widgets(s) return wibox.widget { widgets.tasklist(s), } end --- miggle widget group func +-- middle widget group func function widgets.middle_widgets(s) return wibox.widget { layout = wibox.layout.fixed.horizontal, widgets.textclock, @@ -104,7 +87,7 @@ function widgets.right_widgets(s) return wibox.widget { layout = wibox.layout.fixed.horizontal, { layout = wibox.layout.fixed.horizontal, - spacing = spacing * 2, + spacing = beautiful.margin_leftright * 2, { layout = wibox.layout.fixed.horizontal, widgets.cpu, @@ -117,11 +100,18 @@ function widgets.right_widgets(s) return wibox.widget { { widget = wibox.widget.separator, opacity = 0, - forced_width = spacing + forced_width = beautiful.margin_leftright }, --mylauncher, } end +-- create calendar popup on textclock +local month_calendar = awful.widget.calendar_popup.month() +month_calendar:attach(widgets.textclock, "t", { on_hover = false }) + +-- bind volume popup to volume block +volume_control.dropdown.dropdown:bind_to_widget(widgets.vol) + -- create a wibox for each screen and add it awful.screen.connect_for_each_screen(function (s) awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s, awful.layout.layouts[1]) @@ -134,29 +124,14 @@ awful.screen.connect_for_each_screen(function (s) s.mywibox:setup { layout = wibox.layout.align.horizontal, expand = "none", - spacing = spacing, + spacing = beautiful.margin_leftright, widgets.left_widgets(s), - widgets.middle_widgets(s), + wibox.container.margin( + widgets.middle_widgets(s), + beautiful.margin_leftright, beautiful.margin_leftright, 0, 0 + ), widgets.right_widgets(s), } end) ----- signal for changing tasklist filter based on layout ----- DOESNT WORK TODO ---local naughty = require("naughty") ---s:connect_signal("property::layout", function() --- naughty.notify({ --- title = "Hello, AwesomeWM!", --- text = "This is a notification.", --- timeout = 5, -- Timeout in seconds --- position = "top_right" -- Position on the screen --- }) --- if awful.layout.get(s) == awful.layout.suit.max then --- s.mytasklist.filter = awful.widget.tasklist.filter.currenttags --- else --- s.mytasklist.filter = awful.widget.tasklist.filter.focused --- end ---end ---) - return widgets diff --git a/buttons.lua b/buttons.lua index ff87aae..bce8442 100644 --- a/buttons.lua +++ b/buttons.lua @@ -22,7 +22,7 @@ client_buttons = gears.table.join( -- wibar widgets layout_buttons = gears.table.join( - awful.button({ }, 1, function() awful.layout.inc(1, awful.screen.focused().tags[0]) end), + awful.button({ }, 1, function() awful.layout.inc(1, awful.screen.focused(), awful.layout.layouts) end), awful.button({ }, 2, function() if client.focus and not client.focus.prevent_kill then client.focus:kill() end end) ) diff --git a/func/noborders.lua b/func/noborders.lua index fe67024..83069af 100644 --- a/func/noborders.lua +++ b/func/noborders.lua @@ -2,14 +2,16 @@ local beautiful = require("beautiful") -- TODO this function will call arrange multiple times. once per each change of c.border_width local function update_borders(s) - local max = s.selected_tag.layout.name == "max" + if s.selected_tag == nil then return end + local max = s.selected_tag.layout.name == "max" + local floating = s.selected_tag.layout.name == "floating" local only_one = #s.tiled_clients == 1 -- use tiled_clients so that other floating windows don't affect the count -- but iterate over clients instead of tiled_clients as tiled_clients doesn't include maximized windows for _, c in pairs(s.clients) do if c.prevent_kill then c.border_width = beautiful.border_width * 3 - elseif (max or only_one or c.maximized) and not c.floating then + elseif (max or only_one or c.maximized) and not floating and not c.floating then c.border_width = 0 else c.border_width = beautiful.border_width diff --git a/func/sloppyfocus.lua b/func/sloppyfocus.lua index d044498..298059b 100644 --- a/func/sloppyfocus.lua +++ b/func/sloppyfocus.lua @@ -1,4 +1,5 @@ -- Enable sloppy focus, so that focus follows mouse. client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", { raise = true }) + --c:emit_signal("request::activate", "mouse_enter", { raise = true }) + c:emit_signal("request::activate", "mouse_enter") end) diff --git a/hosts/libreX60.lua b/hosts/libreX60.lua index 294c1a1..af69c6a 100644 --- a/hosts/libreX60.lua +++ b/hosts/libreX60.lua @@ -1,5 +1,11 @@ -local wibox = require("wibox") +local beautiful = require("beautiful") + +beautiful.font_mono = "Tamzen 8" +beautiful.font_mono_bold = "Tamzen, bold 8" +beautiful.font = beautiful.font_mono +beautiful.font_sans = beautiful.font_mono + local bar_widgets = require("bar") bar_widgets.textclock.format = "%a, %b %-e, %-H:%M" -bar_widgets.temp.file = "/sys/class/hwmon/hwmon2/temp1_input" +bar_widgets.temp.file = "/sys/class/thermal/thermal_zone0/temp" diff --git a/keybindings.lua b/keybindings.lua index e731788..611e1ff 100644 --- a/keybindings.lua +++ b/keybindings.lua @@ -64,6 +64,7 @@ globalkeys = gears.table.join( key(w , "m", function () awful.layout.set(awful.layout.suit.max) end, { group = "layout" , description = "change to max layout" }), key(w , "t", function () awful.layout.set(awful.layout.suit.tile) end, { group = "layout" , description = "change to tile layout" }), key(w , "b", function () awful.layout.set(awful.layout.suit.tile.bottom) end, { group = "layout" , description = "change to tile bottom layout" }), + key(w , "f", function () awful.layout.set(awful.layout.suit.floating) end, { group = "layout" , description = "change to floating layout" }), key(w , "r", function () awful.screen.focused().mypromptbox:run() end, { group = "launcher", description = "run prompt" }), key(w , "p", function () menubar.show() end, { group = "launcher", description = "show the menubar" }), -- PC Controls @@ -85,12 +86,15 @@ globalkeys = gears.table.join( key(w , "F7", function () awful.spawn("bl set 50") end, { group = "monitor" , description = "set monitor brightness to 50%" }), key(w , "F8", function () awful.spawn("bl set 100") end, { group = "monitor" , description = "set monitor brightness to 100%" }), key({}, "XF86MonBrightnessUp", function () awful.spawn("bl inc 10") end, { group = "monitor" , description = "increase monitor brightness by 10%" }), - key({}, "XF86MonBrightnessDown", function () awful.spawn("bl dec 10") end, { group = "monitor" , description = "decrease monitor brightness by 10%" }), - -- Volume Controls + key({}, "XF86MonBrightnessDown", function () awful.spawn("bl dec 10") end, { group = "monitor" , description = "decrease monitor brightness by 10%" }) +) + +-- Volume Controls +if pavolctld then globalkeys = gears.table.join(globalkeys, key({}, "XF86AudioRaiseVolume", function () pavolctld.volume_inc(5) end, { group = "volume" , description = "increase volume by 5%" }), key({}, "XF86AudioLowerVolume", function () pavolctld.volume_dec(5) end, { group = "volume" , description = "decrease volume by 5%" }), key({}, "XF86AudioMute", pavolctld.mute_toggle , { group = "volume" , description = "toggle audio mute" }) -) +) end -- Client protection diff --git a/layouts.lua b/layouts.lua index 67fd31d..fb291b3 100644 --- a/layouts.lua +++ b/layouts.lua @@ -5,9 +5,6 @@ awful.layout.layouts = { awful.layout.suit.tile, awful.layout.suit.tile.bottom, awful.layout.suit.max, - awful.layout.suit.floating, - - -- awful.layout.suit.floating, -- awful.layout.suit.tile, -- awful.layout.suit.tile.left, diff --git a/lib/pavolctld.lua b/lib/pavolctld.lua index b6b6237..42babbe 100644 --- a/lib/pavolctld.lua +++ b/lib/pavolctld.lua @@ -10,6 +10,15 @@ local Gio = lgi.Gio -- start subprocess local p = Gio.Subprocess.new({ "pavolctld" }, Gio.SubprocessFlags.STDIN_PIPE + Gio.SubprocessFlags.STDOUT_PIPE) +if p == nil then + -- TODO see if error should be handled another way + naughty.notify({ + preset = naughty.config.presets.critical, + title = "pavolctld error", + text = "pavolctld could not be loaded", + }) + return false +end local stdout = p:get_stdout_pipe() local stdin = p:get_stdin_pipe() @@ -26,7 +35,7 @@ function sinks.get(i) sinks.sinks[i] = { vol = 0, db = 0.0, - mute = 0, + mute = false, name = "", desc = "", } @@ -35,7 +44,7 @@ function sinks.get(i) end -- return table -local pavolctld = { _cb = {}, sinks = sinks } +local pavolctld = { _cb = {}, sinks = sinks, max_volume = 150 } -- callbacks function pavolctld.set_volume_change_callback(cb) pavolctld._cb['v'] = cb end @@ -57,7 +66,7 @@ awful.spawn.read_lines(stdout, function(s) local sink = sinks.get(i) sink.vol = tonumber(v()) sink.db = tonumber(v()) - sink.mute = tonumber(v()) + sink.mute = v() == "1" -- sink description change elseif cmd == 's' then local v = parse_csv(s:sub(2)) diff --git a/lib/wiboxtooltip.lua b/lib/wiboxtooltip.lua new file mode 100644 index 0000000..be56a1f --- /dev/null +++ b/lib/wiboxtooltip.lua @@ -0,0 +1,53 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local gears = require("gears") + +-- TODO more args +-- TODO use tooltip theme vars +function create_wibox_tooltip(parent, widget) + local p = { + parent = parent, + popup = awful.popup { + widget = wibox.container.margin ( + widget, + beautiful.margin_leftright, beautiful.margin_leftright, + beautiful.margin_topbottom, beautiful.margin_topbottom + ), + ontop = true, + visible = false, + preferred_positions = "bottom", + preferred_anchors = "middle", + } + } + -- hover timer + p.timer = gears.timer { + timeout = 1, + single_shot = true, + callback = function() + p.popup:move_next_to(mouse.current_widget_geometry) + p.popup.visible = true + end, + } + -- signal functions + p._mouse_enter = function() + p.timer:again() + end + p._mouse_leave = function() + p.timer:stop() + p.popup.visible = false + end + p.connect_signals = function() + p.parent:connect_signal("mouse::enter", p._mouse_enter) + p.parent:connect_signal("mouse::leave", p._mouse_leave) + end + p.disconnect_signals = function() + p.parent:disconnect_signal("mouse::enter", p._mouse_enter) + p.parent:disconnect_signal("mouse::leave", p._mouse_leave) + end + + p.connect_signals() + return p +end + +return create_wibox_tooltip @@ -11,21 +11,18 @@ osname = uname_i() hostname = uname_i() -- import modules -require("awful.autofocus") -- focus when moving between tags etc. +require("theme") -- load first +require("layouts") -- load before bar +pcall(require, "hosts." .. hostname) -- call override module if one exists +require("keybindings") +require("buttons") +require("bar") +require("rules") require("lib.errors") require("lib.manage") require("lib.screen") -require("layouts") -require("theme") -- load before bar -require("buttons") -- load before bar & rules -require("bar") -require("keybindings") -require("rules") -require("func.noborders") +require("awful.autofocus") -- focus when moving between tags etc. +require("func.noborders") -- no border on require("func.sloppyfocus") ---require("func.warpcursor") require("func.tagnames") ---require("widgets.audio") - --- call override module if exists -pcall(function() require("hosts." .. hostname) end) +--require("func.warpcursor") @@ -1,5 +1,7 @@ local awful = require("awful") local beautiful = require("beautiful") +require("keybindings") +require("buttons") -- Rules to apply to new clients (through the "manage" signal) awful.rules.rules = { @@ -1,5 +1,6 @@ -- theme handling library local beautiful = require("beautiful") +local apply_dpi = beautiful.xresources.apply_dpi local gears = require("gears") -- colors @@ -14,22 +15,22 @@ beautiful.init(gears.filesystem.get_themes_dir() .. "gtk/theme.lua") beautiful.useless_gap = 0 beautiful.gap_single_client = false --- overrides -beautiful.tasklist_font_focus = beautiful.font -- prevent bold -beautiful.wibar_height = math.floor(beautiful.get_font_height(beautiful.font) * 1.15) -beautiful.wibar_bg = darkgray ---beautiful.layoutlist_font = "Monospace 8" ---beautiful.font = "Tamzen 10" ---beautiful.tasklist_align = "center" -- does nothing? - +-- fonts beautiful.font_sans = beautiful.font beautiful.font_mono = "monospace 10" +beautiful.font_mono_bold = "monospace, bold 10" beautiful.font = beautiful.font_mono ---beautiful.layoutlist_font = beautiful.font_mono beautiful.taglist_font = beautiful.font_sans beautiful.tasklist_font = beautiful.font_sans beautiful.textclock_font = beautiful.font_sans +beautiful.tooltip_font = beautiful.font_mono + +-- bar +--beautiful.tasklist_font_focus = beautiful.font -- prevent bold +beautiful.wibar_height = math.floor(beautiful.get_font_height(beautiful.font) * 1.15) +beautiful.wibar_bg = darkgray +beautiful.tasklist_plain_task_name = true -- don't use client status icons -- hotkeys menu beautiful.hotkeys_font = beautiful.font_mono -- TODO make bold @@ -42,17 +43,27 @@ beautiful.hotkeys_modifiers_fg = lightgray beautiful.hotkeys_label_bg = darkgray -- ??? -- slider -beautiful.slider_bar_height = 5 +beautiful.slider_bar_height = apply_dpi(2.5) beautiful.slider_bar_shape = gears.shape.rounded_rect -beautiful.slider_handle_width = 17.5 +beautiful.slider_bar_color = beautiful.border_color +beautiful.slider_handle_width = apply_dpi(10) beautiful.slider_handle_shape = gears.shape.circle -beautiful.slider_handle_color = beautiful.border_color -beautiful.slider_handle_border_color = "#333333" -beautiful.slider_handle_border_width = 1 +--beautiful.slider_handle_color = beautiful.border_color +--beautiful.slider_handle_border_color = "#333333" +--beautiful.slider_handle_border_width = 1 -- progressbar beautiful.progressbar_fg = beautiful.border_focus +-- margins +beautiful.margin_leftright = apply_dpi(5) +beautiful.margin_topbottom = apply_dpi(3) + +-- calendar +beautiful.calendar_header_bg_color = "#333333" +beautiful.calendar_header_border_color = "#222222" +beautiful.calendar_header_border_width = beautiful.border_width + -- set border on clients client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) diff --git a/widgets/classiclayouts.lua b/widgets/classiclayouts.lua index 515e66c..994f520 100644 --- a/widgets/classiclayouts.lua +++ b/widgets/classiclayouts.lua @@ -1,6 +1,8 @@ +local awful = require("awful") local wibox = require("wibox") local layout = require("awful.layout") local beautiful = require("beautiful") +local naughty = require("naughty") local screen_widgets = {} -- need one widget per screen @@ -32,21 +34,22 @@ function update(screen_index) -- create widget if not existing if w == nil then - screen_widgets[s] = { widget = wibox.widget.textbox(), layout = l } - if beautiful.font_mono then - screen_widgets[s].widget.font = beautiful.font_mono - end + screen_widgets[s] = { + widget = wibox.widget { + font = beautiful.layoutbox_font or beautiful.font_mono or "monospace 10", + widget = wibox.widget.textbox, + }, + layout = l, + tooltip = awful.tooltip { delay_show = 1 }, + } w = screen_widgets[s] - --w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} - - -- skip if no change - elseif w.layout == l then - return + w.tooltip:add_to_object(w.widget) end + w.layout = l -- set widget local name = layout.getname(l) - --w._layoutbox_tooltip:set_text(name) + w.tooltip:set_text(name) local wtxt = layout_icons[name] if type(wtxt) == 'function' then wtxt = wtxt(s) @@ -65,14 +68,18 @@ function update_screens() end end -function update_current_tag(t) +function update_tag(t) update(t.screen) end -tag.connect_signal("property::selected", update_current_tag) -tag.connect_signal("property::layout", update_current_tag) -tag.connect_signal("tagged", update_current_tag) -- max -tag.connect_signal("untagged", update_current_tag) -- max +function update_client(c) + update(c.screen) +end + +tag.connect_signal("property::selected", update_tag) +tag.connect_signal("property::layout", update_tag) +tag.connect_signal("tagged", update_client) -- max +tag.connect_signal("untagged", update_client) -- max tag.connect_signal("property::screen", update_screens) return update diff --git a/widgets/pavolctld.lua b/widgets/pavolctld.lua index 3697465..6f257b5 100644 --- a/widgets/pavolctld.lua +++ b/widgets/pavolctld.lua @@ -1,44 +1,23 @@ local awful = require("awful") -local gears = require("gears") local wibox = require("wibox") -local beautiful = require("beautiful") -local menubar = require("menubar") local pavolctld = require("lib.pavolctld") +local volume_dropdown = require("widgets.volumedropdown") + +-- ensure pavolctld loaded +if not pavolctld then return wibox.widget.textbox("err") end -- return table local widget = {} + widget.textbox = wibox.widget.textbox() -widget.dbmeter = wibox.widget.textbox() -widget.vslider = wibox.widget { - { - { - { - value = 50, - max_value = 150, - shape = beautiful.slider_bar_shape, - bg = beautiful.slider_handle_color, - widget = wibox.widget.progressbar, - }, - height = 5, - widget = wibox.container.constraint - }, - halign = "center", - widget = wibox.container.place, - }, - { - bar_height = 0, - widget = wibox.widget.slider, - }, - layout = wibox.layout.stack, -} -widget.defsink = wibox.widget.textbox() widget.tooltip = awful.tooltip { objects = {widget.textbox}, delay_show = 1 } +widget.dropdown = volume_dropdown -- widget callbacks pavolctld.set_volume_change_callback(function() - widget.vslider.value = pavolctld.sinks.default.vol widget.textbox:set_text(pavolctld.sinks.default.vol) - widget.dbmeter:set_text(pavolctld.sinks.default.db .. " dB") + widget.dropdown.set_volume(pavolctld.sinks.default.vol, pavolctld.sinks.default.mute) + widget.dropdown.dbmeter:set_text(pavolctld.sinks.default.db .. " dB") end) pavolctld.set_sink_change_callback(function() @@ -46,102 +25,11 @@ pavolctld.set_sink_change_callback(function() end) pavolctld.set_default_sink_change_callback(function() - widget.vslider.value = pavolctld.sinks.default.vol widget.textbox:set_text(pavolctld.sinks.default.vol) - widget.dbmeter:set_text(pavolctld.sinks.default.db .. " dB") widget.tooltip:set_text(pavolctld.sinks.default.desc) - widget.defsink:set_text(pavolctld.sinks.default.desc) -end) - --- slider -widget.vslider.maximum = 150 -- max in pavolctld -widget.vslider:buttons(volume_buttons) -widget.vslider:connect_signal("property::value", function() - if pavolctld.sinks.default.vol == widget.vslider.value then return end -- help prevent overloading daemon - pavolctld.volume_set(widget.vslider.value) -end) - --- scrollbox for default sink select -local default_sink_scrollbox = wibox.widget { - widget.defsink, - step_function = wibox.container.scroll.step_functions.linear_increase, - speed = 25, - extra_space = 25, -- space between repetition - pause = true, -- start paused - widget = wibox.container.scroll.horizontal, -} - --- scroll when hovering -default_sink_scrollbox:connect_signal("mouse::enter", function() - default_sink_scrollbox:continue() -end) - -default_sink_scrollbox:connect_signal("mouse::leave", function() - default_sink_scrollbox:pause() - default_sink_scrollbox:reset_scrolling() + widget.dropdown.set_volume(pavolctld.sinks.default.vol, pavolctld.sinks.default.mute) + widget.dropdown.dbmeter:set_text(pavolctld.sinks.default.db .. " dB") + widget.dropdown.defsink:set_text(pavolctld.sinks.default.desc) end) --- widget dropdown -local volume_dropdown = wibox.widget { - { - { - { - default_sink_scrollbox, - margins = 5, - widget = wibox.container.margin, - }, - bg = "#333333", - widget = wibox.container.background, - }, - margins = beautiful.border_width, - color = "#222222", - widget = wibox.container.margin, - }, - { - { - text = "M", - widget = wibox.widget.textbox, - }, - { - widget.vslider, - left = 10, - right = 10, - widget = wibox.container.margin, - layout = wibox.layout.stack, - }, - { - widget.dbmeter, - forced_width = 125, - halign = "right", - widget = wibox.container.place, - }, - layout = wibox.layout.align.horizontal, - }, - forced_num_cols = 1, - forced_num_rows = 2, - expand = true, - forced_width = 500, - forced_height = 100, - layout = wibox.layout.grid, -} -widget.dropdown = awful.popup { - widget = { - volume_dropdown, - margins = 15, - widget = wibox.container.margin, - }, - border_color = beautiful.border_focus, - border_width = beautiful.border_width, - shape = gears.shape.rounded_rect, - ontop = true, - hide_on_right_click = true, - preferred_positions = "bottom", - preferred_anchors = 'back', - visible = false, - offset = { y = 5 }, -} - -widget.dropdown:bind_to_widget(widget.textbox) - - return widget diff --git a/widgets/tasklist.lua b/widgets/tasklist.lua new file mode 100644 index 0000000..76616bf --- /dev/null +++ b/widgets/tasklist.lua @@ -0,0 +1,80 @@ +local awful = require("awful") +local wibox = require("wibox") +local wibox_tooltip = require("lib.wiboxtooltip") +local beautiful = require("beautiful") + +local separator = { widget = wibox.widget.separator, opacity = 0 } + +function create_tasklist_widget(s, filter, font_focus) + return awful.widget.tasklist { + screen = s, + filter = filter, + buttons = tasklist_buttons, + widget_template = { + id = "text_role", + widget = wibox.widget.textbox, + align = "center", + }, + style = { + font_focus = font_focus, + }, + } +end + +function create_tasklist(s) + -- allow for different styles for different layouts + local tasklist_focused = create_tasklist_widget(s, awful.widget.tasklist.filter.focused, beautiful.tasklist_font) + local tasklist_currenttags = create_tasklist_widget(s, awful.widget.tasklist.filter.currenttags, beautiful.tasklist_font_focus) + + local change_layout = function(layout) + local max = layout == awful.layout.suit.max + tasklist_currenttags:set_visible(max) + tasklist_focused:set_visible(not max) + end + change_layout(s.selected_tag.layout) + + -- setup widgets + local tasklist = wibox.widget { + layout = wibox.layout.stack, + tasklist_currenttags, + tasklist_focused, + } + + local popup = wibox_tooltip(tasklist, awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + layout = { + layout = wibox.layout.fixed.vertical, + }, + widget_template = { + id = "text_role", + widget = wibox.widget.textbox, + align = "center", + }, + style = { + font_focus = beautiful.font_mono_bold, + }, + }) + + -- setup signals to change tasklist filter on layout changes + local change_layout_from_tag = function(t) + if t.screen ~= s then return end + change_layout(t.layout) + end + tag.connect_signal("property::layout", change_layout_from_tag) + tag.connect_signal("property::selected", change_layout_from_tag) + tag.connect_signal("tagged", change_layout_from_tag) + tag.connect_signal("untagged", change_layout_from_tag) + tag.connect_signal("property::screen", change_layout_from_tag) + + -- return widget + return wibox.widget { + layout = wibox.layout.align.horizontal, + expand = "outside", + separator, + tasklist, + separator, + } +end + +return create_tasklist diff --git a/widgets/volumedropdown.lua b/widgets/volumedropdown.lua new file mode 100644 index 0000000..dad20eb --- /dev/null +++ b/widgets/volumedropdown.lua @@ -0,0 +1,195 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local apply_dpi = beautiful.xresources.apply_dpi +local pavolctld = require("lib.pavolctld") + +-- return table +local widget = {} + +widget.dbmeter = wibox.widget.textbox("-999.99 dB") -- max width text +local dbmeter_maxwidth, _ = widget.dbmeter:get_preferred_size_at_dpi(beautiful.xresources.get_dpi()) -- max width, TODO per screen dpi +dbmeter_maxwidth = dbmeter_maxwidth * 1.5 -- ??? + +local slider = wibox.widget { + bar_height = 0, + widget = wibox.widget.slider, + maximum = pavolctld.max_volume, +} +local progressbar = wibox.widget { + max_value = pavolctld.max_volume, + shape = beautiful.slider_bar_shape, + bg = beautiful.slider_handle_color, + widget = wibox.widget.progressbar, +} +widget.vslider = wibox.widget { + { + { + progressbar, + height = apply_dpi(3), + widget = wibox.container.constraint + }, + halign = "center", + widget = wibox.container.place, + }, + slider, + layout = wibox.layout.stack, +} + +-- scrollbox for default sink select +widget.defsink = wibox.widget.textbox() +local default_sink_scrollbox = wibox.widget { + widget.defsink, + step_function = wibox.container.scroll.step_functions.linear_increase, + speed = apply_dpi(15), + extra_space = apply_dpi(25), -- space between repetition + pause = true, -- start paused + widget = wibox.container.scroll.horizontal, +} + +local muted = wibox.widget { + color = "#222222", + check_color = beautiful.border_focus, + forced_width = apply_dpi(20), + widget = wibox.widget.checkbox, +} + +-- widget dropdown +local volume_dropdown = wibox.widget { + { + { + { + default_sink_scrollbox, + margins = beautiful.margin_topbottom, + widget = wibox.container.margin, + }, + bg = "#333333", + widget = wibox.container.background, + }, + margins = beautiful.border_width, + color = "#222222", + widget = wibox.container.margin, + }, + { + { + { + { + { + text = "Mute:", + widget = wibox.widget.textbox, + }, + left = apply_dpi(5), + right = apply_dpi(5), + widget = wibox.container.margin, + }, + fill_vertical = true, + widget = wibox.container.place, + }, + { + muted, + fill_vertical = true, + widget = wibox.container.place, + }, + layout = wibox.layout.align.horizontal, + }, + fill_vertical = true, + widget = wibox.container.place, + }, + widget.vslider, + { + widget.dbmeter, + halign = "right", + forced_width = dbmeter_maxwidth, + widget = wibox.container.place, + }, + forced_num_cols = 2, + forced_num_rows = 2, + homogeneous = false, + expand = true, + forced_width = apply_dpi(300), + forced_height = apply_dpi(60), + layout = wibox.layout.grid, +} +widget.dropdown = awful.popup { + widget = { + volume_dropdown, + left = beautiful.margin_leftright, + right = beautiful.margin_leftright, + top = beautiful.margin_topbottom, + bottom = beautiful.margin_topbottom, + widget = wibox.container.margin, + }, + border_color = beautiful.border_normal, + border_width = beautiful.border_width, + ontop = true, + hide_on_right_click = true, + preferred_positions = "bottom", + preferred_anchors = "back", + visible = false, +} + +function widget.set_volume(vol, mute) + progressbar:set_value(vol) + muted.checked = mute + if vol == slider.value then return end + slider.value = vol + if widget.dropdown.visible then + slider:emit_signal("widget::redraw_needed") + end +end + +-- slider +slider:buttons(volume_buttons) +slider:connect_signal("property::value", function() + if pavolctld.sinks.default.vol == slider.value then return end + widget.dropdown.visible = true -- make sure widget isn't hidden + pavolctld.volume_set(slider.value) +end) + +-- scroll when hovering +default_sink_scrollbox:connect_signal("mouse::enter", function() + default_sink_scrollbox:continue() +end) + +default_sink_scrollbox:connect_signal("mouse::leave", function() + default_sink_scrollbox:pause() + default_sink_scrollbox:reset_scrolling() +end) + +-- change sink +default_sink_scrollbox:connect_signal("button::press", function() + widget.dropdown.visible = true -- make sure widget isn't hidden + + local g = mouse.current_widget_geometry -- relative to widget.dropdown + local menugeo = { + x = widget.dropdown.x + g.x - beautiful.margin_topbottom, + y = widget.dropdown.y + g.y + g.height + beautiful.margin_topbottom + (beautiful.border_width * 2), + width = g.width + beautiful.margin_topbottom * 2, + } + local menuopts = { items = {}, theme = menugeo } + for i, s in pairs(pavolctld.sinks.sinks) do + table.insert(menuopts.items, { + s.desc, + function() pavolctld.default_sink_set(i) end + }) + end + + if widget.menu then widget.menu:hide() end + widget.menu = awful.menu(menuopts) -- old menu dereferenced, should be cleaned up by gc + widget.menu:show({ coords = menugeo }) +end) + +widget.dropdown:connect_signal("property::visible", function() + if widget.menu then + widget.menu:hide() + widget.menu = nil + end +end) + +-- mute button +muted:connect_signal("button::press", function() + widget.dropdown.visible = true -- make sure widget isn't hidden + pavolctld.mute_toggle() +end) + +return widget |