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,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