Fuxx
This commit is contained in:
parent
8268fba83d
commit
7ed2a6e110
9565 changed files with 1315332 additions and 90 deletions
40
home/.config/awesome/signals/battery.lua
Normal file
40
home/.config/awesome/signals/battery.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
-- ## 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
|
||||
}
|
53
home/.config/awesome/signals/brightness.lua
Normal file
53
home/.config/awesome/signals/brightness.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
-- ## 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)
|
29
home/.config/awesome/signals/disk.lua
Normal file
29
home/.config/awesome/signals/disk.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
-- ## 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
|
||||
}
|
13
home/.config/awesome/signals/init.lua
Normal file
13
home/.config/awesome/signals/init.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
req = {
|
||||
"volume",
|
||||
"brightness",
|
||||
"wifi",
|
||||
"weather",
|
||||
"battery",
|
||||
"player",
|
||||
"disk"
|
||||
}
|
||||
|
||||
for _, x in pairs(req) do
|
||||
require("signals."..x)
|
||||
end
|
39
home/.config/awesome/signals/player.lua
Normal file
39
home/.config/awesome/signals/player.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
-- ## 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
|
||||
}
|
36
home/.config/awesome/signals/volume.lua
Normal file
36
home/.config/awesome/signals/volume.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
-- ## 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
|
||||
}
|
||||
|
||||
|
30
home/.config/awesome/signals/weather.lua
Normal file
30
home/.config/awesome/signals/weather.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
-- ## 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
|
||||
}
|
9
home/.config/awesome/signals/weather_script.sh
Executable file
9
home/.config/awesome/signals/weather_script.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/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
|
46
home/.config/awesome/signals/wifi.lua
Normal file
46
home/.config/awesome/signals/wifi.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
-- ## 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,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue