This commit is contained in:
Luca 2022-11-22 13:25:44 +01:00
parent 8268fba83d
commit 7ed2a6e110
9565 changed files with 1315332 additions and 90 deletions

View file

@ -0,0 +1,214 @@
-- ## Bar ##
-- ~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local gears = require("gears")
local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- # Bar Widgets :
local taglist = require("ui.bar.taglist")
local tasklist = require("ui.bar.tasklist")
local layoutbox = require("ui.bar.layoutbox")
mylayoutbox = wibox.container.margin(layoutbox(s), dpi(4), dpi(4), dpi(4), dpi(4))
-- # Widgets :
-- Keyboard :
--local logout_menu_widget = require("widgets.logout-menu")
local clock_widget = require('widgets.clock')
local keyboardlayout_widget = require('widgets.keyboardlayout')
local mem_widget = require('widgets.memory')
local cpu_widget = require('widgets.cpu')
local temprature_widget = require('widgets.temprature')
local battery_widget = require('widgets.battery')
local brightness_widget = require('widgets.brightness')
local netspeed_widget = require('widgets.net')
mylauncher = wibox.container.margin(mylauncher, dpi(2), dpi(2), dpi(2), dpi(2))
-- Barcontainer :
local function barcontainer(widget)
local container = wibox.widget
{
widget,
top = dpi(0),
bottom = dpi(0),
left = dpi(2),
right = dpi(2),
widget = wibox.container.margin
}
local box = wibox.widget{
{
container,
top = dpi(2),
bottom = dpi(2),
left = dpi(4),
right = dpi(4),
widget = wibox.container.margin
},
bg = colors.container,
shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,0) end,
widget = wibox.container.background
}
return wibox.widget{
box,
top = dpi(2),
bottom = dpi(2),
right = dpi(2),
left = dpi(2),
widget = wibox.container.margin
}
end
-- Separator :
local separator = wibox.widget{
markup = '<span font="' .. theme.font .. '">| </span>',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
-- Systray
local systray = wibox.widget {
visible = true,
base_size = dpi(30),
horizontal = true,
screen = 'primary',
{
{
{
wibox.widget.systray,
layout = wibox.layout.fixed.horizontal,
},
margins = {top = dpi(0), bottom = dpi(0), left = dpi(0), right = dpi(0)},
widget = wibox.container.margin,
},
shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,0) end,
bg = colors.black,
widget = wibox.container.background,
},
margins = {top = dpi(2), bottom = dpi(2)},
widget = wibox.container.margin,
}
-- Logout menu
--local logout_menu = wibox.widget {
-- {
-- {
-- {
-- logout_menu_widget(),
-- layout = wibox.layout.fixed.horizontal,
-- },
-- margins = {top = dpi(0), bottom = dpi(0), left = dpi(0), right = dpi(0)},
-- widget = wibox.container.margin,
-- },
-- shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,0) end,
-- bg = colors.black,
-- widget = wibox.container.background,
-- },
-- margins = {top = dpi(2), bottom = dpi(4)},
-- widget = wibox.container.margin,
--}
--local btn = wibox.widget {
-- wibox.widget.systray,
-- logout_menu_widget(),
-- spacing = dpi(2),
-- layout = wibox.layout.fixed.horizontal
--}
-- Right
local right = wibox.widget {
{
-- # Updates :
barcontainer(netspeed_widget),
-- # Brightness :
--barcontainer(brightness_widget),
-- # CPU TEMP :
barcontainer(temprature_widget),
-- # CPU :
barcontainer(cpu_widget),
-- # RAM :
barcontainer(mem_widget),
-- # Keybord :
barcontainer(keyboardlayout_widget),
-- # Clock :
barcontainer(clock_widget),
-- # Systry :
systray,
-- # Logout :
--logout_menu,
-- # Layoutbox :
--layoutbox(s),
spacing = dpi(4),
layout = wibox.layout.fixed.horizontal,
},
margins = {top = dpi(2), bottom = dpi(2),},
widget = wibox.container.margin,
}
local function get_bar(s)
s.mywibar = awful.wibar({
position = "bottom",
type = "dock",
ontop = false,
stretch = false,
visible = true,
height = dpi(36),
width = s.geometry.width,
screen = s,
bg = colors.black,
--bg = colors.transparent,
--opacity = 0.85,
})
--s.mywibar:struts { bottom = dpi(60), top = dpi(36), left = dpi(20), right = dpi(20) }
s.mywibar:setup({
{
{
layout = wibox.layout.align.horizontal,
--expand = "none",
{ -- Left widgets :
--mylauncher,
barcontainer(taglist(s)),
--taglist(s),
separator,
spacing = dpi(8),
layout = wibox.layout.fixed.horizontal,
},
{ -- Middle widget :
tasklist(s),
layout = wibox.layout.align.horizontal,
},
--tasklist(s),
{ -- Right widgets :
right,
-- # Layoutbox :
mylayoutbox,
layout = wibox.layout.fixed.horizontal,
},
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
},
shape = function(cr,w,h) gears.shape.rounded_rect(cr, w, h, 0) end,
widget = wibox.container.background,
})
end
screen.connect_signal("request::desktop_decoration", function(s)
get_bar(s)
end)

View file

@ -0,0 +1,24 @@
-- ## Layoutbox ##
-- ~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local wibox = require("wibox")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
return function(s)
-- Create a layoutbox widget
local layoutbox = 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),
}
}
layoutbox = wibox.container.margin(layoutbox, dpi(4), dpi(4), dpi(4), dpi(4))
return layoutbox
end

View file

@ -0,0 +1,41 @@
-- ## Tag ##
-- ~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
-- Tags :
awful.util.tagnames = { "", "", "", "", "", "", "", "", ""}
-- Each screen has its own tag table.
screen.connect_signal("request::desktop_decoration", function(s)
awful.tag(awful.util.tagnames, s, awful.layout.layouts[1])
end)
return function(s)
-- Create a taglist widget
local taglist = awful.widget.taglist {
screen = s,
--filter = awful.widget.taglist.filter.all, -- Show All Tags
filter = function (t) return t.selected or #t:clients() > 0 end, -- Show only used Tags
buttons = {
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.viewprev(t.screen) end),
--awful.button({ }, 5, function(t) awful.tag.viewnext(t.screen) end),
}
}
return taglist
end

View file

@ -0,0 +1,81 @@
-- ## Tasklist ##
-- ~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local gears = require("gears")
local awful = require("awful")
local wibox = require("wibox")
return function(s)
-- Create a tasklist widget
local tasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = {
awful.button({ }, 1, function (c)
c:activate { context = "tasklist", action = "toggle_minimization" }
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),
},
style = {
border_width = 0,
border_color = colors.black,
-- Text Enabeld :
shape = function(cr,w,h) gears.shape.rounded_rect(cr, w, h, 0) end,
-- Text disabeld :
--shape = gears.shape.circle,
bg_minimize = colors.black,
bg_normal = colors.brightblack,
bg_focus = colors.brightblack,
},
layout = {
spacing = 2,
spacing_widget = {
{
forced_width = 0,
shape = gears.shape.circle,
widget = wibox.widget.separator
},
valign = "center",
halign = "center",
widget = wibox.container.place,
},
layout = wibox.layout.flex.horizontal
},
widget_template = {
{
{
{
{
-- Icon :
{
id = "clienticon",
widget = awful.widget.clienticon,
},
margins = 2,
widget = wibox.container.margin,
},
-- Text :
--{
-- id = "text_role",
-- widget = wibox.widget.textbox,
--},
layout = wibox.layout.fixed.horizontal,
},
left = 5,
right = 5,
widget = wibox.container.margin
},
id = "background_role",
widget = wibox.container.background,
},
margins = 4,
widget = wibox.container.margin
}
}
return tasklist
end

View file

@ -0,0 +1,52 @@
-- ## Menu ##
-- ~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local menubar = require("menubar")
local awful = require('awful')
local wibox = require('wibox')
local gears = require('gears')
local beautiful = require('beautiful')
local hotkeys_popup = require('awful.hotkeys_popup')
-- {{{ Menu
-- Create a launcher widget and a main menu
myawesomemenu = {
{ " Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
{ " Manual", terminal .. " -e man awesome" },
--{ " Edit config", editor_cmd .. " " .. awesome.conffile },
{ " Restart", awesome.restart },
{ " Quit", function() awesome.quit() end },
}
powermenu = {
{ " Lock", function() awful.spawn.with_shell('notify-send "👉 Locking system " && sleep 1 && betterlockscreen -l') end },
{ " Logout", function() awful.spawn.with_shell('notify-send "👉 Loging out " && sleep 1 && loginctl terminate-session ${XDG_SESSION_ID-}') end },
{ " Suspend", function() awful.spawn.with_shell('notify-send "👉 Suspending 鈴" && sleep 1 && systemctl suspend') end },
{ " Hibernate", function() awful.spawn.with_shell('notify-send "👉 Hibernateing " && sleep 1 && systemctl hibernate') end },
{ " Reboot", function() awful.spawn.with_shell('notify-send "👉 Rebooting " && sleep 1 && reboot') end },
{ " Poweroff", function() awful.spawn.with_shell('notify-send "👉 Powering Off " && sleep 1 && poweroff') end },
}
mymainmenu = awful.menu(
{ items = {
{ "类 Awesome", myawesomemenu },
{ " Terminal", terminal },
{ " Power Menu", powermenu }
}
})
mylauncher = awful.widget.launcher({
image = theme.awesome_icon,
menu = mymainmenu
})
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it

View file

@ -0,0 +1,149 @@
-- ## Notifications ##
-- ~~~~~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require "awful"
local wibox = require "wibox"
local gears = require "gears"
local beautiful = require "beautiful"
local naughty = require "naughty"
local dpi = beautiful.xresources.apply_dpi
naughty.config.defaults.ontop = true
naughty.config.defaults.screen = awful.screen.focused()
naughty.config.defaults.timeout = 5
naughty.config.defaults.title = "Notification"
naughty.config.defaults.position = "top_right"
naughty.config.defaults.border_width = 0
local function create_notifcation(n)
local time = os.date "%H:%M"
local icon_visibility
if n.icon == nil then
icon_visibility = false
else
icon_visibility = true
end
-- Action widget
local action_widget = {
{
{
id = "text_role",
align = "center",
font = "Roboto Mono 10",
widget = wibox.widget.textbox,
},
margins = {left = dpi(6), right = dpi(6)},
widget = wibox.container.margin,
},
widget = wibox.container.background,
}
-- Apply action widget ^
local actions = wibox.widget {
notification = n,
base_layout = wibox.widget {
spacing = dpi(8),
layout = wibox.layout.flex.horizontal,
},
widget_template = action_widget,
widget = naughty.list.actions,
}
local function space_h(length, circumstances)
return wibox.widget {
forced_width = length,
visible = circumstances,
layout = wibox.layout.fixed.horizontal,
}
end
-- Make other widgets
local title = wibox.widget.textbox()
title.font = "Roboto bold 14"
title.align = 'left'
title.markup = n.title
local message = wibox.widget.textbox()
message.font = "Roboto Mono 12"
message.align = 'left'
message.markup = n.message
local icon = wibox.widget {
nil,
{
{
image = n.icon,
visible = icon_visibility,
widget = wibox.widget.imagebox,
},
strategy = "max",
width = dpi(60),
height = dpi(60),
widget = wibox.container.constraint,
},
expand = 'none',
layout = wibox.layout.align.vertical,
}
local container = wibox.widget {
{
title,
{
icon,
space_h(dpi(10), icon_visibility),
message,
layout = wibox.layout.fixed.horizontal,
},
actions,
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
},
margins = dpi(20),
widget = wibox.container.margin,
}
naughty.layout.box {
notification = n,
type = "notification",
bg = beautiful.bg,
border_width = 0,
shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,8) end,
widget_template = {
{
{
{
widget = container,
},
strategy = "max",
width = dpi(620),
widget = wibox.container.constraint,
},
strategy = "min",
width = dpi(160),
height = dpi(80),
widget = wibox.container.constraint,
},
bg = colors.brightblack,
widget = wibox.container.background,
}
}
end
-- # Error handling :
naughty.connect_signal("request::display_error", function(message, startup)
naughty.notification {
urgency = "critical",
title = "Oops, an error happened"..(startup and " during startup!" or "!"),
message = message
}
end)
naughty.connect_signal("request::display", function(n)
create_notifcation(n)
end)

View file

@ -0,0 +1,88 @@
-- ## Calendar ##
-- ~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Creating Calendar
----------------------
-- copied from awesome doc and adjusted a bit
local styles = {}
styles.month = {
bg_color = colors.brightblack,
fg_color = colors.white,
padding = dpi(3),
}
styles.normal = {
bg_color = colors.brightblack,
fg_color = colors.white,
padding = dpi(3),
}
styles.focus = {
fg_color = colors.yellow,
markup = function(t) return '<b>' .. t .. '</b>' end,
padding = dpi(3),
}
styles.header = {
fg_color = colors.brightblue,
markup = function(t) return '<b>' .. t .. '</b>' end,
}
styles.weekday = {
fg_color = colors.white,
markup = function(t) return '<span font_desc="Roboto Medium 14">' .. t .. '</span>' end,
}
-- The Function
local function decorate_cell(widget, flag, date)
if flag=="monthheader" and not styles.monthheader then
flag = "header"
end
local props = styles[flag] or {}
if props.markup and widget.get_text and widget.set_markup then
widget:set_markup(props.markup(widget:get_text()))
end
-- Change bg color for weekends
local d = {year=date.year, month=(date.month or 1), day=(date.day or 1)}
local weekday = tonumber(os.date("%w", os.time(d)))
local ret = wibox.widget {
{
widget,
margins = props.padding,
widget = wibox.container.margin
},
fg = props.fg_color,
bg = props.bg_color,
widget = wibox.container.background
}
return ret
end
local calendar = wibox.widget {
date = os.date("*t"),
font = "Roboto Mono 14",
fn_embed = decorate_cell,
widget = wibox.widget.calendar.month,
}
return wibox.widget {
nil,
{
nil,
calendar,
expand = 'none',
layout = wibox.layout.align.horizontal,
},
expand = 'none',
layout = wibox.layout.align.vertical,
}

View file

@ -0,0 +1,36 @@
-- ## Clock ##
-- ~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Day
local day = wibox.widget.textbox()
day.font = "Roboto bold 8"
day.align = 'center'
local date = wibox.widget.textbox()
date.font = "Roboto bold 10"
date.align = 'center'
gears.timer {
timeout = 60,
call_now = true,
autostart = true,
callback = function()
day.markup = "<span foreground='"..colors.red.."'>"..os.date("%A").."</span>"
date.markup = os.date("%d %B %Y")
end
}
return wibox.widget {
day,
date,
spacing = dpi(4),
layout = wibox.layout.fixed.vertical,
}

View file

@ -0,0 +1,155 @@
-- ## Sidebar ##
-- ~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
local rubato = require("lib.rubato")
-- Var
--------
local width = dpi(420)
local height = awful.screen.focused().geometry.height - dpi(60)
-- Helper
-----------
local function round_widget(radius)
return function(cr,w,h)
gears.shape.rounded_rect(cr,w,h,radius)
end
end
local function center_widget(widgets)
return wibox.widget {
nil,
{
nil,
widgets,
expand = 'none',
layout = wibox.layout.align.horizontal,
},
expand = 'none',
layout = wibox.layout.align.vertical,
}
end
local function box_widget(widgets, width, height)
return wibox.widget {
{
{
widgets,
margins = dpi(16),
widget = wibox.container.margin,
},
forced_width = dpi(width),
forced_height = dpi(height),
shape = round_widget(8),
bg = colors.brightblack,
widget = wibox.container.background,
},
margins = {left = dpi(20), right = dpi(20)},
widget = wibox.container.margin,
}
end
local aa = wibox.widget.textbox()
-- Get widgets
local profile_widget = require("ui.sidebar.profile")
local player_widget = require("ui.sidebar.player")
local sliders_widget = require("ui.sidebar.sliders")
local weather_widget = require("ui.sidebar.weather")
local calendar_widget = require("ui.sidebar.calendar")
-- Combine some widgets
local profile = box_widget(profile_widget, 380, 150)
local sliders = box_widget(sliders_widget, 380, 120)
local player = box_widget(player_widget, 380, 80)
local weather = box_widget(weather_widget, 380, 180)
local calendar = box_widget(calendar_widget, 380, 330)
-- Spacing
local space = function(height)
return wibox.widget {
forced_height = dpi(height),
layout = wibox.layout.align.horizontal
}
end
-- Sidebar
local sidebar = wibox {
visible = false,
ontop = true,
width = width,
height = height,
y = dpi(15),
screen = s,
bg = theme.bg,
--bg = colors.transparent,
shape = round_widget(18),
}
-- Sidebar widget setup
sidebar : setup {
{
profile,
sliders,
weather,
calendar,
spacing = dpi(20),
layout = wibox.layout.fixed.vertical,
},
margins = { top = dpi(20), bottom = dpi(20)},
widget = wibox.container.margin,
}
-- Slide animation
local slide = rubato.timed {
pos = awful.screen.focused().geometry.x - sidebar.width,
rate = 60,
intro = 0.2,
duration = 0.4,
subscribed = function(pos)
sidebar.x = awful.screen.focused().geometry.x + pos
end
}
-- Timer of sidebar's death
sidebar.timer = gears.timer {
timeout = 0.5,
single_shot = true,
callback = function()
sidebar.visible = not sidebar.visible
end
}
-- Toggle function
sidebar.toggle = function(s)
if sidebar.visible then
slide.target = awful.screen.focused().geometry.x - sidebar.width
sidebar.timer:start()
else
slide.target = awful.screen.focused().geometry.x + dpi(10)
sidebar.visible = not sidebar.visible
end
end
--awful.mouse.append_global_mousebindings({
-- awful.button({ }, 1, function () sidebar.toggle() end)
--})
--awful.keyboard.append_global_keybindings({
-- awful.key({alt}, "c", function() awesome.emit_signal("sidebar::toggle") end), -- Sidebar
--})
-- Get signal to execute the function (if that makes sense)
awesome.connect_signal("sidebar::toggle", function(s)
sidebar.toggle()
end)
return sidebar

View file

@ -0,0 +1,116 @@
-- ## Player ##
-- ~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Make Widgets
-----------------²
-- Song's Title
local title = wibox.widget.textbox()
title.font = "Roboto Medium 16"
title.align = "left"
title.valign = "center"
-- Song's Artist
local artist = wibox.widget.textbox()
artist.font = "Roboto Regular 16"
artist.align = "left"
artist.valign = "bottom"
-- Song's Length
local length = wibox.widget.textbox()
length.font = "Roboto Mono Regular 14"
length.align = "center"
length.valign = "center"
-- Player's Button
local toggle = wibox.widget.textbox()
toggle.font = "Roboto 26"
toggle:buttons(gears.table.join(
awful.button({}, 1, function()
awful.spawn("playerctl -i firefox play-pause", false)
if toggle.markup:match("󰐊") then
toggle.markup = "󰏤"
else
toggle.markup = "󰐊"
end
end)
))
local next = wibox.widget.textbox()
next.font = "Roboto 26"
next.markup = "󰒭"
next:buttons(gears.table.join(
awful.button({}, 1, function() awful.spawn("playerctl next", false) end)
))
local back = wibox.widget.textbox()
back.font = "Roboto 26"
back.markup = "󰒮"
back:buttons(gears.table.join(
awful.button({}, 1, function() awful.spawn("playerctl previous", false) end)
))
-- Get data
awesome.connect_signal("signal::player", function(t, a, l, s)
if not s:match("Playing") then
toggle.markup = "󰐊"
else
toggle.markup = "󰏤"
end
title.markup = t
artist.markup = a
length.markup = l
end)
-- Grouping Widgets
---------------------
local buttons = wibox.widget {
back,
toggle,
next,
spacing = dpi(8),
layout = wibox.layout.fixed.horizontal,
}
return wibox.widget {
{
nil,
{
title,
artist,
layout = wibox.layout.fixed.vertical,
},
expand = 'none',
layout = wibox.layout.align.vertical,
},
{
nil,
nil,
{
length,
{
nil,
buttons,
expand = 'none',
layout = wibox.layout.align.horizontal,
},
spacing = dpi(12),
layout = wibox.layout.fixed.vertical,
},
layout = wibox.layout.align.vertical,
},
layout = wibox.layout.flex.horizontal,
}

View file

@ -0,0 +1,146 @@
-- ## Profile ##
-- ~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Helper
-----------
local function round_widget(radius)
return function(cr,w,h)
gears.shape.rounded_rect(cr,w,h,radius)
end
end
-- Create Widgets
-------------------
-- Pfp
local pfp = wibox.widget.imagebox()
pfp.image = theme.pfp
pfp.clip_shape = gears.shape.circle
pfp.forced_width = dpi(130)
pfp.forced_height = dpi(130)
-- User
local user = wibox.widget.textbox()
user.font = "Roboto SemiBold 18"
user.align = 'left'
user.markup = "<span foreground='"..colors.brightwhite.."'>"..theme.user.."</span>"
-- Hostname
local hostname = wibox.widget.textbox()
hostname.font = "Roboto Regular 14"
hostname.align = 'left'
awful.spawn.easy_async_with_shell("cat /proc/sys/kernel/hostname", function(stdout)
hostname.markup = "@"..tostring(stdout)
end)
-- Weather Icon
local weather_icon = wibox.widget.imagebox()
weather_icon.image = theme.weather_icon
weather_icon.forced_width = dpi(70)
weather_icon.forced_height = dpi(47)
-- Temperature
local temperature = wibox.widget.textbox()
temperature.font = "Roboto Medium 20"
temperature.align = 'left'
-- How's the weather?
local the_weather = wibox.widget.textbox()
the_weather.font = "Roboto Medium 14"
the_weather.align = "left"
-- Battery
local bat_desc = wibox.widget.textbox()
bat_desc.font = "Roboto Medium 12"
bat_desc.align = "center"
local battery = wibox.widget {
{
id = "bat_val",
forced_width = dpi(130),
forced_height = dpi(22),
background_color = "#4B6133",
color = colors.green,
shape = round_widget(12),
bar_shape = round_widget(12),
max_value = 100,
widget = wibox.widget.progressbar,
},
{
widget = bat_desc,
},
layout = wibox.layout.stack,
}
-- Get data 4 widgets!
awesome.connect_signal("signal::bat", function(bat_value, bat_preview)
battery.bat_val.value = bat_value
bat_desc.markup = "<span foreground='"..colors.black.."'>"..bat_preview.."</span>"
end)
--awesome.connect_signal("signal::weather", function(hows_weather, feels_like)
-- hows_weather = string.gsub(hows_weather, "'", "")
-- feels_like = string.gsub(feels_like, "\n", "")
-- the_weather.markup = hows_weather
-- temperature.markup = feels_like:match("%d%d").."°C"
--end)
-- Spacing horizontally
local space = wibox.widget {
forced_height = dpi(6),
layout = wibox.layout.align.horizontal
}
-- Grouping widgets
---------------------
local name = wibox.widget {
user,
hostname,
spacing = dpi(4),
layout = wibox.layout.fixed.vertical,
}
local weather = wibox.widget {
{
weather_icon,
temperature,
spacing = dpi(20),
layout = wibox.layout.fixed.horizontal,
},
{
widget = the_weather,
},
spacing = dpi(8),
layout = wibox.layout.fixed.vertical,
}
-- The Profile Widget
return wibox.widget {
{
{
pfp,
--battery,
spacing = dpi(20),
layout = wibox.layout.fixed.vertical,
},
layout = wibox.layout.fixed.vertical,
},
{
name,
battery,
--weather,
layout = wibox.layout.fixed.vertical,
},
spacing = dpi(30),
layout = wibox.layout.fixed.horizontal,
}

View file

@ -0,0 +1,65 @@
-- ## redshift ##
-- ~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
local toggle = wibox.widget.textbox()
toggle.font = theme.sidebar_font
--toggle:buttons(gears.table.join(
-- awful.button({}, 1, function()
-- awful.spawn("redshift -l 0:0 -t 4500:4500 -r &>/dev/null & echo 'ON'", function(stdout))
-- if stdout:match("ON") then
-- toggle.markup = ""
-- else
-- toggle.markup = ""
-- end
-- end)
--))
toggle:buttons(gears.table.join(
awful.spawn.easy_async_with_shell(
[[
if [ ! -z $(pgrep redshift) ];
then
redshift -x && pkill redshift && killall redshift
echo 'OFF'
else
redshift -l 0:0 -t 4500:4500 -r &>/dev/null &
echo 'ON'
fi
]],
function(stdout)
if stdout:match("ON") then
toggle.markup = ""
else
toggle.markup = ""
end
end
),
),
)
local buttons = wibox.widget {
toggle,
spacing = dpi(8),
layout = wibox.layout.fixed.horizontal,
}
return wibox.widget {
{
nil,
buttons,
expand = 'none',
layout = wibox.layout.align.horizontal,
},
spacing = dpi(12),
layout = wibox.layout.fixed.vertical,
}

View file

@ -0,0 +1,222 @@
-- ## Sliders ##
-- ~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Helper
-----------
local function round_widget(radius)
return function(cr,w,h)
gears.shape.rounded_rect(cr,w,h,radius)
end
end
-- Create volume slider
--local volume_icon = wibox.widget.textbox()
--volume_icon.font = theme.sidebar_font
--volume_icon.align = 'left'
--volume_icon.markup = ""
--volume_icon.fg = colors.blue
local v_icon = wibox.widget {
markup = '<span font="' .. theme.sidebar_font .. '"></span>',
widget = wibox.widget.textbox,
}
local volume_icon = wibox.widget{
v_icon,
fg = colors.blue,
widget = wibox.container.background
}
local volume_osd_value = wibox.widget({
text = "0%",
font = theme.font,
align = "center",
valign = "center",
widget = wibox.widget.textbox,
})
local volume_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(10),
bar_shape = round_widget(12),
bar_height = dpi(14),
bar_color = colors.black,
bar_active_color = colors.blue,
handle_shape = gears.shape.circle,
handle_color = colors.brightblue,
handle_width = dpi(20),
widget = wibox.widget.slider
}
volume = wibox.widget {
nil,
{
volume_icon,
volume_slider,
volume_osd_value,
spacing = dpi(20),
layout = wibox.layout.fixed.horizontal,
},
expand = "none",
layout = wibox.layout.align.vertical,
}
local update_volume = function()
awful.spawn.easy_async_with_shell("pamixer --get-volume", function(stdout)
volume_slider.value = tonumber(stdout:match("%d+"))
end)
end
volume_slider:connect_signal("property::value", function(_, vol)
awful.spawn("pamixer --set-volume ".. vol, false)
-- Update textbox widget text
volume_osd_value.text = vol .. "%"
awesome.emit_signal("module::volume_osd_value", vol)
end)
-- Create Mic slider
local m_icon = wibox.widget {
markup = '<span font="' .. theme.sidebar_font .. '"> </span>',
widget = wibox.widget.textbox,
}
local mic_icon = wibox.widget{
m_icon,
fg = colors.green,
widget = wibox.container.background
}
local mic_osd_value = wibox.widget({
text = "0%",
font = theme.font,
align = "center",
valign = "center",
widget = wibox.widget.textbox,
})
local mic_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(10),
bar_shape = round_widget(12),
bar_height = dpi(14),
bar_color = colors.black,
bar_active_color = colors.green,
handle_shape = gears.shape.circle,
handle_color = colors.brightgreen,
handle_width = dpi(20),
widget = wibox.widget.slider
}
local mic = wibox.widget {
nil,
{
mic_icon,
mic_slider,
mic_osd_value,
spacing = dpi(20),
layout = wibox.layout.fixed.horizontal,
},
expand = "none",
layout = wibox.layout.align.vertical,
}
local update_mic = function()
awful.spawn.easy_async_with_shell("pamixer --source alsa_input.usb-1c1f_USB_PnP_Audio_Device-00.mono-fallback --get-volume", function(stdout)
mic_slider.value = tonumber(stdout:match("%d+"))
end)
end
mic_slider:connect_signal("property::value", function(_, mic_vol)
awful.spawn("pamixer --source alsa_input.usb-1c1f_USB_PnP_Audio_Device-00.mono-fallback --set-volume ".. mic_vol, false)
-- Update textbox widget text
mic_osd_value.text = mic_vol .. "%"
awesome.emit_signal("module::mic_osd_value", mic_vol)
end)
-- Create brightness slider
--local bright_icon = wibox.widget.textbox()
--bright_icon.font = theme.sidebar_font
--bright_icon.align = 'left'
--bright_icon.markup = " "
local b_icon = wibox.widget {
markup = '<span font="' .. theme.sidebar_font .. '"> </span>',
widget = wibox.widget.textbox,
}
local bright_icon = wibox.widget{
b_icon,
fg = colors.yellow,
widget = wibox.container.background
}
local bright_osd_value = wibox.widget({
text = "0%",
font = theme.font,
align = "center",
valign = "center",
widget = wibox.widget.textbox,
})
local bright_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(30),
bar_shape = round_widget(12),
bar_height = dpi(14),
bar_color = colors.black,
bar_active_color = colors.yellow,
handle_shape = gears.shape.circle,
handle_color = colors.brightyellow,
handle_width = dpi(20),
widget = wibox.widget.slider
}
bright_slider:connect_signal("property::value", function(_, bri)
awful.spawn("brightnessctl set "..bri.."%", false)
bright_osd_value.text = bri .. "%"
awesome.emit_signal("module::bright_osd_value", bri)
end)
local update_brightness = function()
awful.spawn.easy_async_with_shell("brightnessctl g", function(stdout)
val = tonumber(stdout)
awful.spawn.easy_async_with_shell("brightnessctl max", function(stdout)
bri = val/tonumber(stdout) * 100
bright_slider.value = bri
end)
end)
end
local brightness = wibox.widget {
nil,
{
bright_icon,
bright_slider,
bright_osd_value,
spacing = dpi(20),
layout = wibox.layout.fixed.horizontal,
},
expand = "none",
layout = wibox.layout.align.vertical,
}
gears.timer {
timeout = 10,
autostart = true,
call_now = true,
callback = function()
update_volume()
update_mic()
update_brightness()
end
}
local all_slider = wibox.widget {
volume,
mic,
brightness,
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
}
return all_slider

View file

@ -0,0 +1,139 @@
-- ## Stats ##
-- ~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Helper
-----------
local function round_widget(radius)
return function(cr,w,h)
gears.shape.rounded_rect(cr,w,h,radius)
end
end
local function grouping_widget(w1,w2)
local container = wibox.widget {
w1,
{
nil,
w2,
expand = 'none',
layout = wibox.layout.align.vertical,
},
spacing = dpi(18),
layout = wibox.layout.fixed.horizontal,
}
return container
end
local function center_widget(widget)
return wibox.widget {
nil,
{
nil,
widget,
expand = 'none',
layout = wibox.layout.align.horizontal,
},
expand = 'none',
layout = wibox.layout.align.vertical,
}
end
-- Create_widgets
-------------------
-- Disk
local d_icon = wibox.widget.textbox()
d_icon.font = theme.sidebarfont
d_icon.align = "left"
d_icon.markup = ""
local d_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(10),
color = beautiful.red,
background_color = "#663D3D",
shape = round_widget(12),
bar_shape = round_widget(12),
max_value = 100,
value = 20,
widget = wibox.widget.progressbar,
}
local disk = grouping_widget(d_icon, d_slider)
-- Vol
local v_icon = wibox.widget.textbox()
v_icon.font = theme.sidebarfont
v_icon.align = "left"
v_icon.markup = ""
local v_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(10),
color = beautiful.blue,
background_color = "#3D4B66",
shape = round_widget(12),
bar_shape = round_widget(12),
max_value = 100,
widget = wibox.widget.progressbar,
}
local volume = grouping_widget(v_icon, v_slider)
-- Brightness
local b_icon = wibox.widget.textbox()
b_icon.font = theme.sidebarfont
b_icon.align = "left"
b_icon.markup = ""
local b_slider = wibox.widget {
forced_width = dpi(220),
forced_height = dpi(10),
color = beautiful.yellow,
background_color = "#66523D",
shape = round_widget(12),
bar_shape = round_widget(12),
max_value = 100,
widget = wibox.widget.progressbar,
}
local brightness = grouping_widget(b_icon, b_slider)
-- Getting Value for These Widgets
------------------------------------
local function get_val()
awesome.connect_signal("signal::volume", function(vol, muted)
if muted then v_slider.value = 0 else
v_slider.color = beautiful.blue
v_slider.value = tonumber(vol)
end
end)
awesome.connect_signal("signal::brightness", function(bri)
b_slider.value = tonumber(bri)
end)
awesome.connect_signal("signal::disk", function(disk_perc)
d_slider.value = tonumber(disk_perc)
end)
end
get_val()
return center_widget(wibox.widget {
disk,
volume,
brightness,
spacing = dpi(18),
layout = wibox.layout.fixed.vertical,
})

View file

@ -0,0 +1,48 @@
-- ## Uptime ##
-- ~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Icon
local icon = wibox.widget.textbox()
icon.font = "Roboto Medium 24"
icon.align = 'center'
icon.markup = "<span foreground='"..beautiful.yellow.."'>󰍹</span>"
-- Uptime
local uptime = wibox.widget.textbox()
uptime.font = "Roboto Medium 16"
uptime.align = 'center'
local function get_uptime()
local script = [[
uptime -p
]]
awful.spawn.easy_async_with_shell(script, function(stdout)
stdout = string.gsub(stdout, "\n", "")
uptime.markup = stdout
end)
end
gears.timer {
timeout = 60,
autostart = true,
call_now = true,
callback = function()
get_uptime()
end
}
return wibox.widget {
icon,
uptime,
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
}

View file

@ -0,0 +1,214 @@
local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local filesystem = gears.filesystem
local json = require("lib.json")
local icon_dir = filesystem.get_configuration_dir() .. "themes/icons/weather/"
--- Weather Widget
--- ~~~~~~~~~~~~~~
local GET_FORECAST_CMD = [[bash -c "curl -s --show-error -X GET '%s'"]]
local icon_map = {
["01d"] = "weather-clear-sky",
["02d"] = "weather-few-clouds",
["03d"] = "weather-clouds",
["04d"] = "weather-few-clouds",
["09d"] = "weather-showers-scattered",
["10d"] = "weather-showers",
["11d"] = "weather-strom",
["13d"] = "weather-snow",
["50d"] = "weather-fog",
["01n"] = "weather-clear-night",
["02n"] = "weather-few-clouds-night",
["03n"] = "weather-clouds-night",
["04n"] = "weather-clouds-night",
["09n"] = "weather-showers-scattered",
["10n"] = "weather-showers",
["11n"] = "weather-strom",
["13n"] = "weather-snow",
["50n"] = "weather-fog",
}
local current_weather_widget = wibox.widget({
{
{
id = "icon",
image = icon_dir .. "weather-showers.svg",
resize = true,
forced_height = dpi(42),
forced_width = dpi(42),
widget = wibox.widget.imagebox,
},
{
{
{
id = "description",
text = "Mostly cloudy",
font = "Roboto Medium 10",
widget = wibox.widget.textbox,
},
{
id = "humidity",
text = "Humidity: 80%",
font = "Roboto Medium 10",
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.vertical,
},
widget = wibox.container.place,
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
nil,
{
{
{
id = "tempareture_current",
markup = "20<sup><span>°</span></sup>",
align = "right",
font = "Roboto Medium 14",
widget = wibox.widget.textbox,
},
{
id = "feels_like",
markup = "Feels like: 19<sup><span>°C</span></sup>",
font = "Roboto Medium 10",
widget = wibox.widget.textbox,
},
spacing = dpi(-6),
layout = wibox.layout.fixed.vertical,
},
widget = wibox.container.place,
},
layout = wibox.layout.align.horizontal,
})
local hourly_widget = function()
local widget = wibox.widget({
{
{
id = "time",
text = "12PM",
font = "Roboto Medium 10",
widget = wibox.widget.textbox,
},
widget = wibox.container.place,
},
{
{
id = "icon",
image = icon_dir .. "weather-clear-sky.svg",
resize = true,
forced_height = dpi(16),
forced_width = dpi(16),
widget = wibox.widget.imagebox,
},
widget = wibox.container.place,
},
{
{
id = "tempareture",
markup = "1<sup><span>°</span></sup>",
font = theme.font,
widget = wibox.widget.textbox,
},
widget = wibox.container.place,
},
spacing = dpi(6),
layout = wibox.layout.fixed.vertical,
})
widget.update = function(result)
local time = widget:get_children_by_id("time")[1]
local icon = widget:get_children_by_id("icon")[1]
local temp = widget:get_children_by_id("tempareture")[1]
temp:set_markup(math.floor(result.temp) .. "<sup><span>°</span></sup>")
time:set_text(os.date("%I%p", tonumber(result.dt)))
icon.image = icon_dir .. icon_map[result.weather[1].icon] .. ".svg"
icon:emit_signal("widget::redraw_needed")
end
return widget
end
local hourly_widget_1 = hourly_widget()
local hourly_widget_2 = hourly_widget()
local hourly_widget_3 = hourly_widget()
local hourly_widget_4 = hourly_widget()
local hourly_widget_5 = hourly_widget()
local hourly_widget_6 = hourly_widget()
local weather_widget = wibox.widget({
{
text = "Weather",
font = theme.font,
align = "center",
widget = wibox.widget.textbox,
},
current_weather_widget,
{
hourly_widget_1,
hourly_widget_2,
hourly_widget_3,
hourly_widget_4,
hourly_widget_5,
hourly_widget_6,
spacing = dpi(10),
layout = wibox.layout.flex.horizontal,
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
})
local api_key = "api key"
local coordinates = {"lat", "lon"}
local show_hourly_forecast = true
local show_daily_forecast = true
local units = "metric"
local url = (
"https://api.openweathermap.org/data/2.5/onecall"
.. "?lat="
.. coordinates[1]
.. "&lon="
.. coordinates[2]
.. "&appid="
.. api_key
.. "&units="
.. units
.. "&exclude=minutely"
.. (show_hourly_forecast == false and ",hourly" or "")
.. (show_daily_forecast == false and ",daily" or "")
)
awful.widget.watch(string.format(GET_FORECAST_CMD, url), 600, function(_, stdout, stderr)
if stderr == "" then
local result = json.decode(stdout)
-- Current weather setup
local icon = current_weather_widget:get_children_by_id("icon")[1]
local description = current_weather_widget:get_children_by_id("description")[1]
local humidity = current_weather_widget:get_children_by_id("humidity")[1]
local temp_current = current_weather_widget:get_children_by_id("tempareture_current")[1]
local feels_like = current_weather_widget:get_children_by_id("feels_like")[1]
icon.image = icon_dir .. icon_map[result.current.weather[1].icon] .. ".svg"
icon:emit_signal("widget::redraw_needed")
description:set_text(result.current.weather[1].description:gsub("^%l", string.upper))
humidity:set_text("Humidity: " .. result.current.humidity .. "%")
temp_current:set_markup(math.floor(result.current.temp) .. "<sup><span>°</span></sup>")
feels_like:set_markup("Feels like: " .. math.floor(result.current.feels_like) .. "<sup><span>°</span></sup>")
-- Hourly widget setup
hourly_widget_1.update(result.hourly[1])
hourly_widget_2.update(result.hourly[2])
hourly_widget_3.update(result.hourly[3])
hourly_widget_4.update(result.hourly[4])
hourly_widget_5.update(result.hourly[5])
hourly_widget_6.update(result.hourly[6])
end
end)
return weather_widget

View file

@ -0,0 +1,40 @@
-- ## Wifi ##
-- ~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Icon
local icon = wibox.widget.textbox()
icon.font = "Roboto Medium 24"
icon.align = 'center'
-- Wifi Name
local wifi = wibox.widget.textbox()
wifi.font = "Roboto Medium 16"
wifi.align = 'center'
wifi.markup = "Connecting.." -- In case it's still fetching wifi name
awesome.connect_signal("signal::wifi", function(connected, ssid)
if connected then
ssid = tostring(ssid)
ssid = ssid:match("(.-)[:]")
icon.markup = "<span foreground='"..beautiful.green.."'>󰤨</span>"
wifi.markup = ssid
else
icon.markup = "<span foreground='"..beautiful.red.."'>󰤭</span>"
wifi.markup = "Not Connected ;-;"
end
end)
return wibox.widget {
icon,
wifi,
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal
}

View file

@ -0,0 +1,70 @@
-- ## Titlebars ##
-- ~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local gears = require("gears")
local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful")
local gears = require("gears")
local dpi = beautiful.xresources.apply_dpi
----- Titlebar/s -----
client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar
local buttons = {
awful.button({ }, 1, function()
c:activate { context = "titlebar", action = "mouse_move" }
end),
awful.button({ }, 3, function()
c:activate { context = "titlebar", action = "mouse_resize"}
end),
}
-- Set the titlebar :
local titlebar = awful.titlebar(c, {
size = dpi(30),
position = 'top',
})
-- Titlebar :
titlebar:setup {
{
{
{ -- Left
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = 'center',
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{-- Right
--awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.minimizebutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.closebutton (c),
--awful.titlebar.widget.stickybutton (c),
--awful.titlebar.widget.ontopbutton (c),
spacing = dpi(4),
layout = wibox.layout.fixed.horizontal,
},
layout = wibox.layout.align.horizontal,
},
margins = { top = dpi(6), bottom = dpi(6), left = dpi(6), right = dpi(6)},
widget = wibox.container.margin,
},
id = 'background_role',
widget = wibox.container.background,
}
end)