clean 🫠

This commit is contained in:
Luca 2023-02-05 03:06:17 +01:00
parent d3435e53a4
commit d16174b447
9565 changed files with 0 additions and 1315422 deletions

View file

@ -1,40 +0,0 @@
-- ## Battery ##
-- ~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local beautiful = require ("beautiful")
local have_battery = [[
bash -c '
cat /sys/class/power_supply/BAT?/capacity 2>/dev/null | head -1
'
]]
local bat_value
local bat_desc
local function get_bat()
awful.spawn.easy_async(have_battery, function(stdout)
if not stdout:match("%d+") then
bat_value = 0
bat_desc = "No Battery"
awesome.emit_signal("signal::bat", bat_value, bat_desc)
else
bat_value = tonumber(stdout)
bat_desc = bat_value.." %"
awesome.emit_signal("signal::bat", bat_value, bat_desc)
end
end)
end
gears.timer {
timeout = 5,
call_now = true,
autostart = true,
callback = function()
get_bat()
end
}

View file

@ -1,53 +0,0 @@
-- ## Brightness ##
-- ~~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
-- Provides:
-- signal::brightness
-- percentage (integer)
-- Subscribe to backlight changes
-- Requires inotify-tools
local brightness_subscribe_script = [[
bash -c "
while (inotifywait -e modify /sys/class/backlight/?**/brightness -qq) do echo; done
"]]
local brightness_script = [[
sh -c "
brightnessctl g
"]]
local brightness_max = [[
sh -c "
brightnessctl m
"]]
local emit_brightness_info = function()
awful.spawn.with_line_callback(brightness_script, {
stdout = function(value)
awful.spawn.with_line_callback(brightness_max, {
stdout = function(max)
percentage = tonumber(value)/tonumber(max) * 100
percentage = tonumber(percentage) or 0
awesome.emit_signal("signal::brightness", percentage)
end})
end
})
end
-- Run once to initialize widgets
emit_brightness_info()
-- Kill old inotifywait process
awful.spawn.easy_async_with_shell("ps x | grep \"inotifywait -e modify /sys/class/backlight\" | grep -v grep | awk '{print $1}' | xargs kill", function ()
-- Update brightness status with each line printed
awful.spawn.with_line_callback(brightness_subscribe_script, {
stdout = function(_)
emit_brightness_info()
end
})
end)

View file

@ -1,29 +0,0 @@
-- ## Disk ##
-- ~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local which_disk = "/dev/sda2"
local function get_disk()
local script = [[
df -kH -B 1MB ]]..which_disk..[[ | tail -1 | awk '{printf $5}'
]]
awful.spawn.easy_async_with_shell(script, function(disk_perc)
disk_perc = disk_perc:match("%d+")
awesome.emit_signal("signal::disk", disk_perc)
end)
end
gears.timer {
timeout = 2000,
call_now = true,
autostart = true,
callback = function()
get_disk()
end
}

View file

@ -1,13 +0,0 @@
req = {
"volume",
"brightness",
"wifi",
"weather",
"battery",
"player",
"disk"
}
for _, x in pairs(req) do
require("signals."..x)
end

View file

@ -1,39 +0,0 @@
-- ## Player ##
-- ~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
-- Script
local title_sc = 'playerctl -i firefox metadata xesam:title'
local artist_sc = 'playerctl -i firefox metadata xesam:artist'
local length_sc = 'playerctl -i firefox metadata --format "{{duration(position)}}/{{duration(mpris:length)}}"'
local status_sc = 'playerctl -i firefox status'
-- function
local function get_player()
awful.spawn.easy_async_with_shell(title_sc, function(title)
awful.spawn.easy_async_with_shell(artist_sc, function(artist)
awful.spawn.easy_async_with_shell(length_sc, function(length)
awful.spawn.easy_async_with_shell(status_sc, function(status)
title = string.gsub(title, "\n", "")
artist = string.gsub(artist, "\n", "")
length = string.gsub(length, "\n", "")
status = string.gsub(status, "\n", "")
awesome.emit_signal("signal::player", title, artist, length, status)
end)
end)
end)
end)
end
gears.timer {
timeout = 5,
call_now = true,
autostart = true,
callback = function()
get_player()
end
}

View file

@ -1,36 +0,0 @@
-- ## Volume ##
-- ~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require ("wibox")
local vol_sc = 'pamixer --get-volume'
local mute_sc = 'pamixer --get-mute'
local function get_vol()
awful.spawn.easy_async_with_shell(vol_sc, function(vol)
awful.spawn.easy_async_with_shell(mute_sc, function(mute)
if mute:match("false") then
muted = false
else
muted = true
end
awesome.emit_signal("signal::volume", vol, muted)
end)
end)
end
gears.timer {
timeout = 2,
call_now = true,
autostart = true,
callback = function()
get_vol()
end
}

View file

@ -1,30 +0,0 @@
-- ## Wearther ##
-- ~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local city = "" -- Ex. London or Salt+Lake+City
local get_weather = function()
local script = [[
bash -c "$HOME/.config/awesome/signals/weather_script.sh ]] .. city.. [["
]]
awful.spawn.easy_async_with_shell(script, function(stdout)
local weather = stdout:match("(.+):")
local feels_like = stdout:match(".+[:](.+)")
awesome.emit_signal('signal::weather', weather, feels_like)
end)
end
gears.timer {
timeout = 1200,
call_now = true,
autostart = true,
callback = function()
get_weather()
end
}

View file

@ -1,9 +0,0 @@
#!/bin/sh
# This script is used to find weather
city=$1
weather=$(curl -sf "wttr.in/$city?format='%C:%f'")
if [[ ! -z $weather ]]; then
echo $weather
else
echo "Weather unavailable"
fi

View file

@ -1,46 +0,0 @@
-- ## Wifi ##
-- ~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local old_net_ssid = "Reconnect"
local old_net_stat = false
local check_wifi = function()
local script = [[
nmcli -t connection show --active
]]
awful.spawn.easy_async_with_shell(
script,
function(stdout)
local net_ssid = stdout
local net_stat = true
if net_ssid == "" then
net_stat = false
net_ssid = "Not Connected"
end
if net_ssid ~= old_net_ssid then -- Emit signal if there was a change
awesome.emit_signal("signal::wifi", net_stat, net_ssid)
old_net_ssid = net_ssid
old_net_stat = net_stat
end
end
)
end
check_wifi()
gears.timer {
timeout = 3,
autostart = true,
call_now = true,
callback = function()
check_wifi()
end,
}