diff options
Diffstat (limited to 'awesome/bar.lua')
-rw-r--r-- | awesome/bar.lua | 287 |
1 files changed, 126 insertions, 161 deletions
diff --git a/awesome/bar.lua b/awesome/bar.lua index 523beec..4adddb3 100644 --- a/awesome/bar.lua +++ b/awesome/bar.lua @@ -1,181 +1,146 @@ -local gears = require("gears") local awful = require("awful") -require("awful.autofocus") --- Widget and layout library local wibox = require("wibox") --- Theme handling library local beautiful = require("beautiful") --- Notification library -local naughty = require("naughty") -local menubar = require("menubar") -local hotkeys_popup = require("awful.hotkeys_popup") --- Enable hotkeys help widget for VIM and other apps --- when client with a matching name is opened: -require("awful.hotkeys_popup.keys") - --- Load widgets -local widget_cpu_usage = require("widgets.cpu") -local widget_ram_usage = require("widgets.ram") +-- load widgets +--local mylauncher = require("widgets.button") +local widget_cpu_usage = require("widgets.cpu") +local widget_ram_usage = require("widgets.ram") local widget_temperature = require("widgets.temperature") -local classiclayoutbox = require("widgets.classiclayoutbox") -local volume_control = require("widgets.pavolctld") +local classiclayoutbox = require("widgets.classiclayouts") +local volume_control = require("widgets.pavolctld") local widget_volume = volume_control.textbox --- Menu --- Create a launcher widget and a main menu -myawesomemenu = { - { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end }, +-- store widgets here +local spacing = 8 +local separator = { widget = wibox.widget.separator, opacity = 0 } + +local widgets = { + spacing = spacing, -- constant + layoutlist = wibox.widget { + layout = wibox.layout.fixed.horizontal, + buttons = layout_buttons, + wibox.container.margin( + classiclayoutbox(s), + spacing, spacing, 0, 0 + ), + }, + taglist = function(s) return awful.widget.taglist { + screen = s, + 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 = wibox.widget.textclock("%A, %B %e, %-I:%M %p"), + cpu = wibox.widget { + layout = wibox.layout.fixed.horizontal, + wibox.widget.textbox "CPU: ", + widget_cpu_usage, + wibox.widget.textbox "% ", + widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", + wibox.widget.textbox "°", + }, + ram = { + layout = wibox.layout.fixed.horizontal, + wibox.widget.textbox "RAM: ", + widget_ram_usage, + wibox.widget.textbox "%", + }, + vol = { + layout = wibox.layout.fixed.horizontal, + buttons = volume_buttons, + wibox.widget.textbox "VOL: ", + widget_volume, + wibox.widget.textbox "%", + }, } -mymainmenu = awful.menu({ - items = { - { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal } - } -}) - -mylauncher = awful.widget.launcher({ - image = beautiful.awesome_icon, - menu = mymainmenu -}) - --- Menubar configuration -menubar.utils.terminal = terminal -- Set the terminal for applications that require it - --- Wibar --- Create a textclock widget ---mytextclock = wibox.widget.textclock("%A, %B %e, %-I:%M %p") --- x60 -mytextclock = wibox.widget.textclock("%a, %b %e, %-H:%M") - --- Create a wibox for each screen and add it -local taglist_buttons = gears.table.join( - awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end end), - awful.button({ }, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) if client.focus then client.focus:toggle_tag(t) end end), - awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) -) - -local tasklist_buttons = gears.table.join( - awful.button({ }, 1, function (c) c:emit_signal("request::activate", "tasklist", {raise = true}) end), - awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end), - awful.button({ }, 4, function () awful.client.focus.byidx(1) end), - awful.button({ }, 5, function () awful.client.focus.byidx(-1) end) -) - -local volume_buttons = gears.table.join( - awful.button({ }, 4, function() volume_control.volume_inc(5) end), - awful.button({ }, 5, function() volume_control.volume_dec(5) end) -) - +-- left widget group func +function widgets.left_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + spacing = spacing, + { + layout = wibox.layout.fixed.horizontal, + widgets.layoutlist, + widgets.taglist(s), + }, + widgets.tasklist(s), +} end + +-- miggle widget group func +function widgets.middle_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + widgets.textclock, +} end + +-- right widget group func +function widgets.right_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + { + layout = wibox.layout.fixed.horizontal, + spacing = spacing, + widgets.cpu, + widgets.ram, + widgets.vol, + }, + { + widget = wibox.widget.separator, + opacity = 0, + forced_width = spacing + }, + --mylauncher, +} end + +-- 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]) s.mypromptbox = awful.widget.prompt() - --s.mylayoutbox = awful.widget.layoutbox { - -- screen = s, - -- buttons = { - -- awful.button({ }, 1, function () awful.layout.inc( 1) end), - -- awful.button({ }, 3, function () awful.layout.inc(-1) end), - -- awful.button({ }, 4, function () awful.layout.inc(-1) end), - -- awful.button({ }, 5, function () awful.layout.inc( 1) end), - -- } - --} - - - -- Create the wibox + -- create the wibox s.mywibox = awful.wibar({ position = "top", screen = s }) - -- Add widgets to the wibox + -- add widgets to the wibox s.mywibox:setup { layout = wibox.layout.align.horizontal, expand = "none", - spacing = 8, - -- Left widgets - { - layout = wibox.layout.fixed.horizontal, - spacing = 8, - { - layout = wibox.layout.fixed.horizontal, - --awful.widget.layoutbox(s), - classiclayoutbox(s), - awful.widget.taglist { - screen = s, - filter = awful.widget.taglist.filter.noempty, - buttons = taglist_buttons, - }, - }, - { - layout = wibox.layout.align.horizontal, - expand = "outside", - wibox.widget { widget = wibox.widget.separator, opacity = 0 }, - 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", - }, - }, - wibox.widget { widget = wibox.widget.separator, opacity = 0 }, - }, - }, - -- Middle widget - { - layout = wibox.layout.fixed.horizontal, - mytextclock, - }, - -- Right widgets - { - layout = wibox.layout.fixed.horizontal, - spacing = 8, - { - layout = wibox.layout.fixed.horizontal, - wibox.widget.textbox "CPU: ", - widget_cpu_usage, - wibox.widget.textbox "% ", - widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", - wibox.widget.textbox "°", - }, - { - layout = wibox.layout.fixed.horizontal, - wibox.widget.textbox "RAM: ", - widget_ram_usage, - wibox.widget.textbox "%", - }, - { - layout = wibox.layout.fixed.horizontal, - buttons = volume_buttons, - wibox.widget.textbox "VOL: ", - widget_volume, - wibox.widget.textbox "%", - }, - mylauncher, - }, + spacing = spacing, + widgets.left_widgets(s), + widgets.middle_widgets(s), + widgets.right_widgets(s), } - - ---- Signal for changing tasklist filter based on layout - ---- DOESNT WORK TODO - --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 - --) - 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 |