New Setup 📦

This commit is contained in:
Luca 2023-02-05 05:02:49 +01:00
parent d16174b447
commit 415dbd08a1
10194 changed files with 1368647 additions and 4 deletions

View file

@ -0,0 +1,89 @@
-- ## 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",
start_sunday = true,
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,153 @@
-- ## Sidebar ##
-- ~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
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 = helpers.rrect(theme.rounded),
bg = colors.container,
widget = wibox.container.background,
},
margins = {left = dpi(20), right = dpi(20)},
widget = wibox.container.margin,
}
end
-- 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")
local services_widget = require("ui.sidebar.services")
-- Combine some widgets
local profile = box_widget(profile_widget, 380, 150)
local sliders = box_widget(sliders_widget, 380, 120)
local weather = box_widget(weather_widget, 380, 180)
local player = box_widget(player_widget, 380, 150)
local calendar = box_widget(calendar_widget, 380, 330)
local services = box_widget(services_widget, 380, 200)
-- Spacing
local space = function(height)
return wibox.widget {
forced_height = dpi(height),
layout = wibox.layout.align.horizontal
}
end
-- Sidebar
local sidebar = wibox {
type = "dock",
--screen = screen.primary,
visible = false,
ontop = true,
width = dpi(420),
height = dpi(836),
y = dpi(8),
bg = theme.bg,
--bg = colors.main_transparent,
shape = helpers.rrect(18),
}
-- Sidebar widget setup
sidebar : setup {
{
profile,
sliders,
weather,
player,
--calendar,
services,
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 = helpers.screen.geometry.height,
rate = 60,
intro = 0.2,
duration = 0.4,
subscribed = function(pos)
sidebar.y = helpers.screen.geometry.y + 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()
if sidebar.visible then
slide.target = helpers.screen.geometry.y - sidebar.height
sidebar.timer:start()
else
slide.target = helpers.screen.geometry.y + dpi(10)
sidebar.visible = not sidebar.visible
end
end
awful.placement.top_right(sidebar, {honor_workarea = true, margins = beautiful.useless_gap * 3})
--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(s)
end)
return sidebar

View file

@ -0,0 +1,289 @@
-- ## Minimal music widget ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local playerctl = require("libs.bling").signal.playerctl.lib()
-- widgets
----------
-- gradientee music album art
-- - - - - - - - - - - - - -
local music_art_filter = wibox.widget({
{
bg = {
type = "linear",
from = { 0, 0 },
to = { 0, 150},
stops = {
{ 0, colors.transparent},
{ 1, colors.container }
},
},
forced_height = dpi(85),
forced_width = dpi(85),
widget = wibox.container.background,
},
direction = "east",
widget = wibox.container.rotate,
})
-- the different music elements
-- - - - - - - - - - - - - - -
-- album art
local album_art = wibox.widget{
widget = wibox.widget.imagebox,
clip_shape = helpers.rrect(theme.rounded),
forced_height = dpi(85),
forced_width = dpi(85),
image = theme.album_art
}
-- playing yeah?
local playing_or = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("Now playing", colors.white),
font = theme.font,
align = "left",
valign = "center"
}
-- song artist
local song_artist = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("Unknown", colors.white),
font = theme.font,
align = "left",
valign = "center"
}
-- song name
local song_name = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("None", colors.white),
font = theme.font,
align = "left",
valign = "center"
}
---------------------------------------- eo.Widgets
-- buttons
----------
-- toggle button
local toggle_button = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("", colors.white),
font = theme.sidebar_font,
align = "right",
valign = "center"
}
-- next button
local next_button = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("", colors.white),
font = theme.sidebar_font,
align = "right",
valign = "center"
}
-- prev button
local prev_button = wibox.widget{
widget = wibox.widget.textbox,
markup = helpers.colorize_text("", colors.white),
font = theme.sidebar_font,
align = "right",
valign = "center"
}
local music_bar = wibox.widget({
max_value = 100,
value = 0,
background_color = colors.black,
-- shape = gears.shape.rounded_bar,
color = colors.main_scheme,
forced_height = dpi(6),
forced_width = dpi(100),
widget = wibox.widget.progressbar,
})
--------------------------------- eo.buttons
-- update widgets
-----------------
-- commands for different actions
local toggle_command = function() playerctl:play_pause() end
local prev_command = function() playerctl:previous() end
local next_command = function() playerctl:next() end
-- make it functional!
toggle_button:buttons(gears.table.join(
awful.button({}, 1, function() toggle_command() end)))
next_button:buttons(gears.table.join(
awful.button({}, 1, function() next_command() end)))
prev_button:buttons(gears.table.join(
awful.button({}, 1, function() prev_command() end)))
-- update widgets
-----------------
-- title, artist, album art
playerctl:connect_signal("metadata", function(_, title, artist, album_path, __, ___, ____)
if title == "" then
title = "None"
end
if artist == "" then
artist = "Unknown"
end
if album_path == "" then
album_path = theme.album_art
end
album_art:set_image(gears.surface.load_uncached(album_path))
song_name:set_markup_silently(helpers.colorize_text(title, colors.white))
song_artist:set_markup_silently(helpers.colorize_text(artist, colors.white))
end)
-- playing/paused/{N/A}
playerctl:connect_signal("playback_status", function(_, playing, __)
if playing then
toggle_button.markup = helpers.colorize_text("", colors.white)
else
toggle_button.markup = helpers.colorize_text("", colors.white)
end
end)
-- time elapsed
playerctl:connect_signal("position", function(_, interval_sec, length_sec)
music_bar.value = (interval_sec / length_sec) * 100
music_length = length_sec
end)
-- mainbox
-- too messy
------------
local music_box = wibox.widget {
{
{
album_art,
music_art_filter,
layout = wibox.layout.stack,
},
{
{
{
playing_or,
nil,
{
{
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
widget = wibox.container.scroll.horizontal,
forced_width = dpi(250),
speed = 30,
song_name,
},
{
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
widget = wibox.container.scroll.horizontal,
forced_width = dpi(250),
speed = 30,
song_artist,
},
spacing = dpi(2),
layout = wibox.layout.fixed.vertical,
},
layout = wibox.layout.align.vertical,
expand = "none"
},
layout = wibox.layout.fixed.horizontal,
spacing = dpi(10)
},
widget = wibox.container.margin,
margins = {top = dpi(20), bottom = dpi(20), left = dpi(20), right = dpi(20)},
},
layout = wibox.layout.stack,
},
widget = wibox.container.background,
forced_height = dpi(150),
bg = colors.container,
border_color = colors.container,
shape = helpers.rrect(theme.rounded)
}
-- finalize
-----------
return wibox.widget {
{
music_box,
{
{
music_bar,
direction = "east",
widget = wibox.container.rotate,
forced_width = dpi(2)
},
layout = wibox.layout.fixed.horizontal,
spacing = dpi(20),
},
{
{
{
nil,
{
prev_button,
toggle_button,
next_button,
layout = wibox.layout.fixed.vertical,
spacing = dpi(22)
},
layout = wibox.layout.align.vertical,
expand = "none"
},
left = 17, right = 17,
widget = wibox.container.margin
},
bg = colors.brightblack,
widget = wibox.container.background,
},
layout = wibox.layout.fixed.horizontal,
spacing = dpi(0)
},
widget = wibox.container.background,
bg = colors.container,
shape = helpers.rrect(theme.rounded)
}
-- eof
------

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 Regular 12"
bat_desc.align = "center"
local battery = wibox.widget {
{
id = "bat_val",
forced_width = dpi(130),
forced_height = dpi(22),
background_color = colors.green,
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,137 @@
-- ## Airplane button/widget ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
-- misc/vars
-- ~~~~~~~~~
local service_name = "Airplane"
local service_icon = ""
-- widgets
-- ~~~~~~~
-- icon
local icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text(service_icon, colors.white),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
-- name
local name = wibox.widget{
font = theme.font,
widget = wibox.widget.textbox,
markup = helpers.colorize_text(service_name, colors.white),
valign = "center",
align = "center"
}
-- animation :love:
local circle_animate = wibox.widget{
widget = wibox.container.background,
shape = helpers.rrect(theme.rounded),
bg = colors.main_scheme,
forced_width = 110,
forced_height = 0,
}
-- mix those
local alright = wibox.widget{
{
{
nil,
{
circle_animate,
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal,
expand = "none"
},
{
nil,
{
icon,
name,
layout = wibox.layout.fixed.vertical,
spacing = dpi(10)
},
layout = wibox.layout.align.vertical,
expand = "none"
},
layout = wibox.layout.stack
},
shape = helpers.rrect(theme.rounded),
widget = wibox.container.background,
border_color = colors.brightblack,
forced_width = dpi(80),
forced_height = dpi(80),
bg = colors.brightblack,
}
local animation_button_opacity = rubato.timed{
pos = 0,
rate = 60,
intro = 0.08,
duration = 0.3,
awestore_compat = true,
subscribed = function(pos)
circle_animate.opacity = pos
end
}
-- function that updates everything
local function update_everything(value)
if value then
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(0)
else
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(1)
end
end
awesome.connect_signal("signal::airplane", function (value)
if value then
update_everything(true)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("rfkill block wlan && rfkill block bluetooth", false)
update_everything(false)
end)
)
)
else
update_everything(false)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("rfkill unblock wlan on && rfkill unblock bluetooth", false)
update_everything(true)
end)
)
)
end
end)
return alright

View file

@ -0,0 +1,138 @@
-- ## Bluetooth button/widget ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
-- misc/vars
-- ~~~~~~~~~
local service_name = "Bluetooth"
local service_icon = ""
-- widgets
-- ~~~~~~~
-- icon
local icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text(service_icon, colors.white),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
-- name
local name = wibox.widget{
font = theme.font,
widget = wibox.widget.textbox,
markup = helpers.colorize_text(service_name, colors.white),
valign = "center",
align = "center"
}
-- animation :love:
local circle_animate = wibox.widget{
widget = wibox.container.background,
shape = helpers.rrect(theme.rounded),
bg = colors.main_scheme,
forced_width = 110,
}
-- mix those
local alright = wibox.widget{
{
{
nil,
{
circle_animate,
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal,
expand = "none"
},
{
nil,
{
icon,
name,
layout = wibox.layout.fixed.vertical,
spacing = dpi(10)
},
layout = wibox.layout.align.vertical,
expand = "none"
},
layout = wibox.layout.stack
},
shape = helpers.rrect(theme.rounded),
widget = wibox.container.background,
border_color = colors.brightblack,
forced_width = dpi(80),
forced_height = dpi(80),
bg = colors.brightblack,
}
local animation_button_opacity = rubato.timed{
pos = 0,
rate = 60,
intro = 0.08,
duration = 0.3,
awestore_compat = true,
subscribed = function(pos)
circle_animate.opacity = pos
end
}
-- function that updates everything
local function update_everything(value)
if value then
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(1)
else
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(0)
end
end
awesome.connect_signal("signal::bluetooth", function (value, isrun)
if value then
update_everything(true)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("bluetoothctl power off", false)
update_everything(false)
end)
)
)
else
update_everything(false)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("bluetoothctl power on", false)
update_everything(true)
end)
)
)
end
end)
return alright

View file

@ -0,0 +1,55 @@
-- ## Services buttons ##
-- ~~~~~~~~~~~~~~~~~~~~~~
-- each button has a fade animation when activated
-- Requirements :
-- ~~~~~~~~~~~~~~
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local wibox = require("wibox")
-- widgets
-- ~~~~~~~
local wifi = require("ui.sidebar.services.wifi")
local bluetooth = require("ui.sidebar.services.bluetooth")
local airplane = require("ui.sidebar.services.airplane")
local night_light = require("ui.sidebar.services.redshift")
-- Bottom setup
local bottom_space = wibox.widget{
night_light,
--airplane,
layout = wibox.layout.align.horizontal,
spacing = dpi(25),
}
-- return
-- ~~~~~~
local returner = wibox.widget{
--{
{
wifi,
bluetooth,
airplane,
night_light,
layout = wibox.layout.fixed.horizontal,
spacing = dpi(8),
--expand = "none",
},
----bottom_space,
--spacing = dpi(25),
--layout = wibox.layout.fixed.vertical,
--},
widget = wibox.container.margin,
margins = {top = dpi(4), bottom = dpi(4), left = dpi(0), right = dpi(0)},
}
return returner

View file

@ -0,0 +1,41 @@
-- ## Simple file read / writer ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local file_reader = {}
local information_dir ="/tmp/"
-- Return true if file exists and is readable.
local check_exits = function(path)
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
-- Read an entire file.
file_reader.readall = function(filename)
if check_exits(information_dir .. filename) then
local fh = assert(io.open(information_dir .. filename, "rb"))
local infor = assert(fh:read("*a"))
fh:close()
return tostring(infor:gsub("%s+", ""))
else
return "not found"
end
end
-- Write a string to a file.
file_reader.write = function(filename, contents)
if check_exits(information_dir .. filename) then
local fh = assert(io.open(information_dir .. filename, "wb"))
fh:write(contents)
fh:flush()
fh:close()
end
end
return file_reader

View file

@ -0,0 +1,144 @@
-- ## Redshift button/widget ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
-- misc/vars
-- ~~~~~~~~~
local service_name = "Night Light"
local service_icon = ""
-- widgets
-- ~~~~~~~
-- icon
local icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text(service_icon, colors.white),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
-- name
local name = wibox.widget{
font = theme.font,
widget = wibox.widget.textbox,
markup = helpers.colorize_text(service_name, colors.white),
valign = "center",
align = "center"
}
-- animation :love:
local circle_animate = wibox.widget{
widget = wibox.container.background,
shape = helpers.rrect(theme.rounded),
bg = colors.main_scheme,
forced_width = 110,
}
-- mix those
local alright = wibox.widget{
{
{
nil,
{
circle_animate,
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal,
expand = "none"
},
{
nil,
{
icon,
name,
layout = wibox.layout.fixed.vertical,
spacing = dpi(10)
},
layout = wibox.layout.align.vertical,
expand = "none"
},
layout = wibox.layout.stack
},
shape = helpers.rrect(theme.rounded),
widget = wibox.container.background,
border_color = colors.brightblack,
forced_width = dpi(80),
forced_height = dpi(80),
bg = colors.brightblack
}
local animation_button_opacity = rubato.timed{
pos = 0,
rate = 60,
intro = 0.08,
duration = 0.3,
awestore_compat = true,
subscribed = function(pos)
circle_animate.opacity = pos
end
}
-- kill every redshift process
local readwrite = require("ui.sidebar.services.read_writer")
local output = readwrite.readall("blue_light_state")
if output:match("true") then
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(1)
else
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(0)
end
-- buttons
alright:buttons(gears.table.join(awful.button({}, 1, nil, function()
awful.spawn.easy_async_with_shell(
[[
if [ ! -z $(pgrep redshift) ];
then
redshift -x && pkill redshift && killall redshift
echo "false" > /tmp/blue_light_state
echo 'OFF'
else
redshift -l 0:0 -t 4500:4500 -r &>/dev/null &
echo "true" > /tmp/blue_light_state
echo 'ON'
fi
]],
function(stdout)
if stdout:match("ON") then
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(1)
else
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(0)
end
end
)
end)))
return alright

View file

@ -0,0 +1,135 @@
-- ## Wifi button/widget ##
-- ~~~~~~~~~~~~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
-- misc/vars
-- ~~~~~~~~~
local service_name = "Wi-fi"
local service_icon = ""
-- widgets
-- ~~~~~~~
-- icon
local icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text(service_icon, colors.white),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
-- name
local name = wibox.widget{
font = theme.font,
widget = wibox.widget.textbox,
markup = helpers.colorize_text(service_name, colors.white),
valign = "center",
align = "center"
}
-- animation :love:
local circle_animate = wibox.widget{
widget = wibox.container.background,
shape = helpers.rrect(theme.rounded),
bg = colors.main_scheme,
forced_width = 110,
forced_height = 0,
}
-- mix those
local alright = wibox.widget{
{
{
nil,
{
circle_animate,
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal,
expand = "none"
},
{
nil,
{
icon,
name,
layout = wibox.layout.fixed.vertical,
spacing = dpi(10)
},
layout = wibox.layout.align.vertical,
expand = "none"
},
layout = wibox.layout.stack
},
shape = helpers.rrect(theme.rounded),
widget = wibox.container.background,
border_color = colors.brightblack,
forced_width = dpi(80),
forced_height = dpi(80),
bg = colors.brightblack,
}
local animation_button_opacity = rubato.timed{
pos = 0,
rate = 60,
intro = 0.08,
duration = 0.3,
awestore_compat = true,
subscribed = function(pos)
circle_animate.opacity = pos
end
}
-- function that updates everything
local function update_everything(value)
if value then
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(1)
else
icon.markup = helpers.colorize_text(service_icon, colors.black)
name.markup = helpers.colorize_text(service_name, colors.black)
animation_button_opacity:set(0)
end
end
awesome.connect_signal("signal::wifi", function (value)
if value then
update_everything(true)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("nmcli radio wifi off", false)
update_everything(false)
end)
)
)
else
update_everything(false)
alright:buttons(gears.table.join(
awful.button( {}, 1, function ()
awful.spawn("nmcli radio wifi on", false)
update_everything(true)
end)
)
)
end
end)
return alright

View file

@ -0,0 +1,206 @@
-- ## Sliders ##
-- ~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
-- Create volume slider :
local volume_icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text("", colors.blue),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
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 = helpers.rrect(dpi(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 mic_icon = wibox.widget{
font = theme.sidebar_font,
markup = helpers.colorize_text("", colors.green),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
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 = helpers.rrect(dpi(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{
font = theme.sidebar_font,
markup = helpers.colorize_text("", colors.green),
widget = wibox.widget.textbox,
valign = "center",
align = "center"
}
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 = helpers.rrect(dpi(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(string.format("%.0f", stdout))
awful.spawn.easy_async_with_shell("brightnessctl max", function(stdout)
bri = val/tonumber(string.format("%.0f", stdout)) * 100
bri = tonumber(string.format("%.0f", bri)) or 0
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='"..colors.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,219 @@
-- Requirements :
-- ~~~~~~~~~~~~~~
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 icon_dir = filesystem.get_configuration_dir() .. "themes/icons/weather/"
-- # Libs :
-- ~~~~~~~~
local json = require("libs.json")
--- 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 = ""
local coordinates = {"", ""}
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
}