summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2021-04-06 10:28:29 +0200
committerache <ache@ache.one>2021-04-06 10:28:29 +0200
commit3c78c10c7a9fc733a4135cc5d6c5c19ec0ab4f0a (patch)
treef0b05c7bd828e04475df8f92938fe00f71b3cc88
parentMore color (diff)
Big update !
-rw-r--r--rc.lua203
1 files changed, 139 insertions, 64 deletions
diff --git a/rc.lua b/rc.lua
index 84650ec..17eb3a6 100644
--- a/rc.lua
+++ b/rc.lua
@@ -10,7 +10,8 @@ local beautiful = require("beautiful")
local naughty = require("naughty")
local vicious = require("vicious")
local menubar = require("menubar")
--- local lfs = require'lfs'
+local lfs = require('lfs')
+
awful.screen = require("awful.screen")
local hotkeys = require("awful.hotkeys_popup")
@@ -39,17 +40,16 @@ awesome.quit = function()
end
function guess_wifi(d)
-
- -- for file in lfs.dir(d) do
- -- if lfs.attributes(d .. file,"mode") == "directory" then
- -- local ok = ""
- -- for l in lfs.dir("/sys/class/net/" .. file) do
- -- if l == "wireless" then
- -- return file
- -- end
- -- end
- -- end
- -- end
+ for file in lfs.dir(d) do
+ if lfs.attributes(d .. file,"mode") == "directory" then
+ local ok = ""
+ for l in lfs.dir("/sys/class/net/" .. file) do
+ if l == "wireless" then
+ return file
+ end
+ end
+ end
+ end
end
@@ -87,12 +87,18 @@ editor_cmd = terminal .. " -e " .. editor
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
+lain.layout.cascade.offset_x = 64
+lain.layout.cascade.offset_y = 20
+
-- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = {
- lain.layout.uselessfairnogap, --3
+ awful.layout.suit.fair, --1
+ -- lain.layout.uselessfairnogap, --3
+ lain.layout.uselessfair, --3
+ lain.layout.cascade, --3
+ lain.layout.cascade.tile, --3
awful.layout.suit.tile, --1
awful.layout.suit.floating, --1
- lain.layout.uselesspiral, --2
}
-- }}}
@@ -144,18 +150,20 @@ mytextclock = awful.widget.textclock("<span color='#cbcbcb'> %H:%M</span>")
markup = lain.util.markup
-- Calendar
-lain.widgets.calendar:attach(mytextclock)
+lain.widget.cal {
+ attach_to = {mytextclock},
+}
-- CPU
-cpuwidget = lain.widgets.cpu({
+cpuwidget = lain.widget.cpu({
settings = function()
int_cpu_usage = tonumber(cpu_now.usage)
- widget:set_markup(markup("#cb66cb", "") .. cpu_now.usage .. "%")
+ widget:set_text("⚙️ ".. cpu_now.usage .. "%")
end, timeout=10})
-- MPD
--- mpdwidget = lain.widgets.mpd()
+-- mpdwidget = lain.widget.mpd()
gputemp = wibox.widget.textbox()
vicious.register(gputemp, vicious.widgets.thermal, {"sys"}, 5)
@@ -184,35 +192,56 @@ vicious.register(mpdwidget, vicious.widgets.mpd,
)
-- MEM
-memwidget = lain.widgets.mem({
+memwidget = lain.widget.mem({
settings = function()
int_mem_now_used = tonumber(mem_now.used)
- widget:set_markup(markup.fg.color("#dda", mem_now.used .. "M"))
+ widget:set_markup(markup.fg.color("#dda", "🐏 " .. mem_now.used .. "M (" .. mem_now.perc .. "%)"))
+
+ if notify_ram and mem_now.perc >= 85 then
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = "Niveau de RM",
+ text = "L'utilisation de la RAM dépasse 85%",
+ bg="#EEAA55"})
+ end
end, timeout=5
})
-- ALSA volume
-volumewidget = lain.widgets.alsa({
+volumewidget = lain.widget.alsa({
settings = function()
header = " "
int_volume_level = tonumber(volume_now.level)
if int_volume_level == 100 then
- vlevel = "MX"
+ vlevel = "100"
elseif int_volume_level == 0 then
- vlevel = "MM"
+ vlevel = "0"
else
vlevel = volume_now.level
end
+ volume_emoji = "📢 "
+ if int_volume_level == 0 then
+ volume_emoji = "🔇 "
+ elseif int_volume_level < 30 then
+ volume_emoji = "🔈 "
+ elseif int_volume_level < 50 then
+ volume_emoji = "🔉 "
+ elseif int_volume_level < 90 then
+ volume_emoji = "🔊 "
+ end
+
if volume_now.status == "off" then
vlevel = vlevel .. "#"
+ volume_emoji = "🔇"
else
vlevel = vlevel .. "%"
end
- widget:set_markup(markup.fg.color("#ccaacc", vlevel))
+
+ widget:set_markup(markup.fg.color("#ccaacc", volume_emoji .. vlevel))
+
end , timeout=3})
-- Separators
@@ -225,6 +254,7 @@ mybatwidget = wibox.widget.textbox ('')
mynetworkwidget = wibox.widget.textbox ('')
notify_bat = true
+notify_ram = true
notify_email = true
local lastIp = ''
@@ -243,28 +273,29 @@ function act()
nPercent = tonumber(string.sub(percent,2,a-1))
if nPercent > 30 then
- mybatwidget:set_markup_silently( markup("#19DF1D", "🔋") .. string.sub(percent, 1, a+1))
+ color = "#19DF1D"
elseif nPercent > 10 then
- mybatwidget:set_markup_silently( markup("#E28126", "🔋") .. string.sub(percent, 1, a+1))
+ color = "#E28126"
else
- mybatwidget:set_markup_silently( markup("#E61E1E", "🔋") .. string.sub(percent, 1, a+1))
+ color = "#FF8080"
end
+
+ mybatwidget:set_markup_silently( markup(color, "🔋 " .. nPercent) .. "%")
+
if notify_bat then
- -- str = awful.util.shell("acpi | cut -d',' -f2")
- if percent == " 21%\n" or percent == " 20%\n" then
- naughty.notify({ preset = naughty.config.presets.critical,
+ if nPercent < 22 and nPercent >= 18 then
+ naughty.notify({ preset = naughty.config.presets.normal,
title = "Niveau de batterie",
text = "Niveau de batterie inquiétant."
.. "Pensez à trouver une prise" })
end
- if percent == " 8%\n" or percent == " 9%\n" or
- percent == " 10%\n" then
+ if nPercent < 12 and nPercent >= 7 then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Alerte niveau de batterie",
text = "Niveau de batterie faible,"
.. "pensez à charger le portable" })
end
- if percent == " 4%\n" or percent == " 5%\n" then
+ if nPercent < 4 then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Attention niveau batterie critique !",
text = "Plus que quelque minutes avant un manque d'energie."
@@ -272,15 +303,16 @@ function act()
end
end
end)
- else
- awful.spawn.easy_async("bash -c \"acpi | cut -d',' -f2 \"",
- function(percent, stderr, reason, exit_code)
- a,b = string.find( percent, "%%")
- if a then
- mybatwidget:set_text ("🔌" .. string.sub(percent, 1, a+1))
- end
- end)
- end
+ else
+ awful.spawn.easy_async("bash -c \"acpi | cut -d',' -f2 \"",
+ function(percent, stderr, reason, exit_code)
+ a, b = string.find( percent, "%%")
+ nPercent = tonumber(string.sub(percent,2,a-1))
+ if a then
+ mybatwidget:set_text ("🔌 " .. nPercent .. "%")
+ end
+ end)
+ end
end)
--{{ Network
@@ -289,37 +321,61 @@ function act()
if not ( interface_default == "" or interface_default == "\n") then
interface_default = string.gsub(interface_default, "\n", "")
if not (interface_default == lastInt) then
- naughty.notify({ preset = naughty.config.presets.normal,
- title = "ip change",
- text = "Changement d'interface par defaut " .. lastInt .. " par "
- .. interface_default,
- timeout=20})
+ if not lastInt == "" then
+ naughty.notify({ preset = naughty.config.presets.normal,
+ title = "ip change",
+ text = "Changement d'interface par defaut " .. lastInt .. " par "
+ .. interface_default,
+ timeout=20})
+ else
+ naughty.notify({ preset = naughty.config.presets.normal,
+ title = "new ip",
+ text = "Connection à " .. interface_default,
+ timeout=20})
+ end
lastInt = interface_default
end
awful.spawn.easy_async("bash -c \"ip r | grep 'dev " .. interface_default .. "' | grep src | head -n 1 | sed 's/.*src/src/' | cut -d' ' -f 2 | cut -z -f1\"",
+
function(ip, stderr2, reason3, exit_code3)
+
toShow = ""
if not ( ip == "" or ip == "\n") then
ip = string.gsub(ip, "\n", "")
toShow = ip .. "@"
if not (ip == lastIp) then
- naughty.notify({ preset = naughty.config.presets.normal,
- title = "ip route",
- text = "Changement de route " .. lastIp ..
- " to " .. ip,
- timeout=20})
+ if not lastIp == "" then
+ naughty.notify({ preset = naughty.config.presets.normal,
+ title = "ip route",
+ text = "Changement de route " .. lastIp ..
+ " vers " .. ip,
+ timeout=20})
+ else
+ naughty.notify({ preset = naughty.config.presets.normal,
+ title = "ip route",
+ text = "Initialisation de la route par defaut vers " .. ip,
+ timeout=20})
+ end
lastIp = ip
end
end
+
toShow = toShow .. interface_default
+
+
+
interface_wifi = guess_wifi("/sys/class/net/")
- awful.spawn.easy_async("bash -c \"printf '%b' $(iwconfig " .. interface_wifi .." 2>&1 | grep -v 'no wireless' | grep ESSID | grep -v 'off/any' | tail -n 1 | cut -d'\\\"' -f 2)\"",
- function(essid, stderr2, reason2, exit_code2)
- if not (essid == "" ) then
+
+
+ if interface_wifi ~= "" then
+ awful.spawn.easy_async("bash -c \"printf '%b' $(iwconfig " .. interface_wifi .." 2>&1 | grep -v 'no wireless' | grep ESSID | grep -v 'off/any' | tail -n 1 | cut -d'\\\"' -f 2)\"",
+ function(essid, stderr2, reason2, exit_code2)
+ if essid ~= "" then
essid = string.gsub(essid, "\n", "")
+ toShow = toShow .. " \"" .. essid .. "\" on " .. interface_wifi
- if not (essid == lastEssid) then
+ if essid ~= lastEssid then
naughty.notify({ preset = naughty.config.presets.normal,
title = "Connection Wifi",
text = "Connecté à " .. essid .. " !",
@@ -333,19 +389,20 @@ function act()
awful.spawn.easy_async("bash -c \"ip a s " .. interface_wifi .. " | grep 'inet ' | cut -d' ' -f 6\"",
function(ip_wifi, stderr, reason, exit_code)
ip_wifi = string.gsub(ip_wifi, "\n", "")
- mynetworkwidget:set_text ( "" .. ip_wifi .. "@" .. interface_wifi .. " " .. essid .. "#" .. signal .. " / " .. toShow)
+ toShow = toShow .. " #" .. signal .. " " .. ip_wifi
end)
end
)
- else
mynetworkwidget:set_text ( toShow )
end
+ end
+ )
end
- )
+ mynetworkwidget:set_text ( toShow )
end
)
else
- mynetworkwidget:set_markup( "<s>ip</s>" )
+ mynetworkwidget:set_markup("")
end
end
)
@@ -447,11 +504,11 @@ for s = 1, screen.count() do
right_layout:add(mpdwidget)
right_layout:add(mynetworkwidget)
right_layout:add(spr)
- right_layout:add(cpuwidget)
+ right_layout:add(cpuwidget.widget)
right_layout:add(spr)
- right_layout:add(memwidget)
+ right_layout:add(memwidget.widget)
right_layout:add(spr)
- right_layout:add(volumewidget)
+ right_layout:add(volumewidget.widget)
right_layout:add(spr)
right_layout:add(mybatwidget)
right_layout:add(spr)
@@ -711,6 +768,14 @@ awful.key({ modkey, "Shift" }, "s", hotkeys_popup.show_help, {descriptio
end,
{description = "Toggle battery warning", group = "awesome"}),
+ awful.key({ modkey, "Control" }, "b", function ()
+ notify_ram = not notify_ram
+ naughty.notify({ preset = naughty.config.presets.normal, timeout=1,
+ text = "Notification de ressource RAM: " .. ( notify_ram and "activée" or "désactivée" )})
+
+ end,
+ {description = "Toggle RAM limite warning", group = "awesome"}),
+
awful.key({ modkey, "Shift" }, "e", function ()
notify_email = not notify_email
naughty.notify({ preset = naughty.config.presets.normal, timeout=1,
@@ -736,9 +801,18 @@ awful.key({ modkey, "Shift" }, "s", hotkeys_popup.show_help, {descriptio
]]
awful.util.spawn("rofi -show run -modi run -matching fuzzy")
end,{description = "Run rofi prompt", group = "awesome"}),
+ awful.key({ modkey }, "*",
+ function ()
+ awful.prompt.run {
+ prompt = "Run Lua code: ",
+ textbox = awful.screen.focused().mypromptbox.widget,
+ exe_callback = awful.util.eval,
+ history_path = awful.util.get_cache_dir() .. "/history_eval"
+ }
+ end,{description = "Run Lua code", group = "awesome"}),
awful.key({ modkey }, "!",
function ()
- awful.util.spawn("physlock")
+ awful.util.spawn("xsecurelock")
end,{description = "🔐 lock screen", group = "awesome"}),
awful.key({ modkey }, ":",
function ()
@@ -1030,6 +1104,7 @@ awful.rules.rules = {
awful.util.spawn_with_shell("xbindkeys")
awful.util.spawn_with_shell("autoWall")
awful.util.spawn_with_shell("setxkbmap -option grab:break_actions")
+awful.util.spawn_with_shell("xss-lock -n /usr/lib/xsecurelock/dimmer -l -- /usr/bin/xsecurelock")
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)