Compare commits
25 Commits
develop
...
ashpie-edi
Author | SHA1 | Date | |
---|---|---|---|
106294ce3e | |||
1267074193 | |||
ea20dae2b7 | |||
81dc1817f5 | |||
8c8d729395 | |||
23301aec85 | |||
7c6162d51a | |||
a0024216e8 | |||
6db061641d | |||
034462f8f8 | |||
0bda31d908 | |||
e8a91d98ce | |||
55ff9a842d | |||
dcaf31a930 | |||
66c0c041c1 | |||
4d0173f7e6 | |||
2ff77572ff | |||
6e975df154 | |||
4b7ab5f5ff | |||
0873d1719d | |||
cd1f142003 | |||
1d1cd0550a | |||
b5ca1e485c | |||
a6b0a8b02a | |||
b5f391f3b8 |
58
config.lua
58
config.lua
@ -1,3 +1,61 @@
|
|||||||
local config = require("default_config")
|
local config = require("default_config")
|
||||||
|
|
||||||
|
local awful = require("awful")
|
||||||
|
local gears = require("gears")
|
||||||
|
|
||||||
|
config.awesome.tiling.layouts = {
|
||||||
|
awful.layout.suit.tile,
|
||||||
|
awful.layout.suit.floating,
|
||||||
|
awful.layout.suit.tile.left,
|
||||||
|
awful.layout.suit.tile.bottom,
|
||||||
|
awful.layout.suit.tile.top,
|
||||||
|
-- awful.layout.suit.fair,
|
||||||
|
-- awful.layout.suit.fair.horizontal,
|
||||||
|
-- awful.layout.suit.spiral,
|
||||||
|
-- awful.layout.suit.spiral.dwindle,
|
||||||
|
-- awful.layout.suit.max,
|
||||||
|
-- awful.layout.suit.max.fullscreen,
|
||||||
|
-- awful.layout.suit.magnifier,
|
||||||
|
-- awful.layout.suit.corner.nw,
|
||||||
|
-- awful.layout.suit.corner.ne,
|
||||||
|
-- awful.layout.suit.corner.sw,
|
||||||
|
-- awful.layout.suit.corner.se,
|
||||||
|
}
|
||||||
|
|
||||||
|
config.autostart = gears.table.join(config.autostart,
|
||||||
|
{
|
||||||
|
"nextcloud",
|
||||||
|
"discord-canary",
|
||||||
|
"/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1",
|
||||||
|
"tabs-app",
|
||||||
|
"/usr/lib/kdeconnectd",
|
||||||
|
"kdeconnect-indicator",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
config.widgets.system_resources.bars.screens = { 1, 2, 3 }
|
||||||
|
|
||||||
|
config.keys.custom_keys = {
|
||||||
|
{
|
||||||
|
hotkey = {
|
||||||
|
{ config.keys.modkey, },
|
||||||
|
"e"
|
||||||
|
},
|
||||||
|
action = function()
|
||||||
|
awful.spawn('pcmanfm')
|
||||||
|
end,
|
||||||
|
identity = { description = "pcmanfm", group = "utilities" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hotkey = {
|
||||||
|
{ config.keys.modkey, },
|
||||||
|
'Print'
|
||||||
|
},
|
||||||
|
action = function()
|
||||||
|
awful.spawn('sh -c ~/scripts/flameshot_upload.sh')
|
||||||
|
end,
|
||||||
|
identity = { description = "Upload screeshot", group = "utilities" }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
@ -171,7 +171,8 @@ config.widgets = {
|
|||||||
battery = {
|
battery = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
screens = { 1, 2 },
|
screens = { 1, 2 },
|
||||||
refresh_interval = 30, -- In seconds
|
refresh_interval = 15, -- In seconds
|
||||||
|
list_refresh_interval = 2, -- In seconds
|
||||||
precision = 0, -- How many decimals
|
precision = 0, -- How many decimals
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
139
simple/init.lua
139
simple/init.lua
@ -132,6 +132,9 @@ if config.widgets.keyboard_layout.enabled then
|
|||||||
end
|
end
|
||||||
hotkey.registerKeys(keyboard_layout.getKeys(config.keys.global_keys.keyboard_layout))
|
hotkey.registerKeys(keyboard_layout.getKeys(config.keys.global_keys.keyboard_layout))
|
||||||
|
|
||||||
|
-- Force set default keyboard layout
|
||||||
|
awful.spawn(config.widgets.keyboard_layout.layout_switch_command .. ' ' .. config.widgets.keyboard_layout.layouts[1])
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Auto start
|
-- Auto start
|
||||||
@ -197,23 +200,24 @@ os_menu = awful.widget.launcher({
|
|||||||
|
|
||||||
-- {{{ Wibar
|
-- {{{ Wibar
|
||||||
-- Create a textclock widget
|
-- Create a textclock widget
|
||||||
mytextclock = wibox.widget.textclock()
|
main_clock = wibox.widget.textclock(" %F · %R ")
|
||||||
|
utc_clock = wibox.widget.textclock(" %T UTC ¤ ", 1, "Z")
|
||||||
|
|
||||||
-- Create a wibox for each screen and add it
|
-- Create a wibox for each screen and add it
|
||||||
local taglist_buttons = gears.table.join(awful.button({}, 1, function(t) t:view_only() end),
|
-- local taglist_buttons = gears.table.join(awful.button({}, 1, function(t) t:view_only() end),
|
||||||
awful.button({ config.keys.modkey }, 1, function(t)
|
-- awful.button({ config.keys.modkey }, 1, function(t)
|
||||||
if client.focus then
|
-- if client.focus then
|
||||||
client.focus:move_to_tag(t)
|
-- client.focus:move_to_tag(t)
|
||||||
end
|
-- end
|
||||||
end),
|
-- end),
|
||||||
awful.button({}, 3, awful.tag.viewtoggle),
|
-- awful.button({}, 3, awful.tag.viewtoggle),
|
||||||
awful.button({ config.keys.modkey }, 3, function(t)
|
-- awful.button({ config.keys.modkey }, 3, function(t)
|
||||||
if client.focus then
|
-- if client.focus then
|
||||||
client.focus:toggle_tag(t)
|
-- client.focus:toggle_tag(t)
|
||||||
end
|
-- end
|
||||||
end),
|
-- end),
|
||||||
awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end),
|
-- awful.button({}, 4, function(t) awful.tag.viewnext(t.screen) end),
|
||||||
awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end))
|
-- awful.button({}, 5, function(t) awful.tag.viewprev(t.screen) end))
|
||||||
|
|
||||||
local tasklist_buttons = gears.table.join(awful.button({}, 1, function(c)
|
local tasklist_buttons = gears.table.join(awful.button({}, 1, function(c)
|
||||||
if c == client.focus then
|
if c == client.focus then
|
||||||
@ -266,11 +270,11 @@ awful.screen.connect_for_each_screen(function(s)
|
|||||||
awful.button({}, 4, function() awful.layout.inc(1) end),
|
awful.button({}, 4, function() awful.layout.inc(1) end),
|
||||||
awful.button({}, 5, function() awful.layout.inc(-1) end)))
|
awful.button({}, 5, function() awful.layout.inc(-1) end)))
|
||||||
-- Create a taglist widget
|
-- Create a taglist widget
|
||||||
s.mytaglist = awful.widget.taglist {
|
-- s.mytaglist = awful.widget.taglist {
|
||||||
screen = s,
|
-- screen = s,
|
||||||
filter = awful.widget.taglist.filter.all,
|
-- filter = awful.widget.taglist.filter.all,
|
||||||
buttons = taglist_buttons
|
-- buttons = taglist_buttons
|
||||||
}
|
-- }
|
||||||
|
|
||||||
-- Create a tasklist widget
|
-- Create a tasklist widget
|
||||||
s.mytasklist = awful.widget.tasklist {
|
s.mytasklist = awful.widget.tasklist {
|
||||||
@ -330,7 +334,7 @@ awful.screen.connect_for_each_screen(function(s)
|
|||||||
-- Left widgets
|
-- Left widgets
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
launcher,
|
launcher,
|
||||||
s.mytaglist,
|
-- s.mytaglist,
|
||||||
s.mypromptbox,
|
s.mypromptbox,
|
||||||
},
|
},
|
||||||
s.mytasklist, -- Middle widget
|
s.mytasklist, -- Middle widget
|
||||||
@ -341,7 +345,8 @@ awful.screen.connect_for_each_screen(function(s)
|
|||||||
matchesScreen(config.widgets.system_resources.battery.screens) and system_resources_widget.battery or nil,
|
matchesScreen(config.widgets.system_resources.battery.screens) and system_resources_widget.battery or nil,
|
||||||
keyboard_layout_widget,
|
keyboard_layout_widget,
|
||||||
wibox.widget.systray(),
|
wibox.widget.systray(),
|
||||||
mytextclock,
|
utc_clock,
|
||||||
|
main_clock,
|
||||||
s.mylayoutbox,
|
s.mylayoutbox,
|
||||||
os_menu,
|
os_menu,
|
||||||
},
|
},
|
||||||
@ -546,50 +551,50 @@ clientkeys = gears.table.join(-- tiling
|
|||||||
-- Bind all key numbers to tags.
|
-- Bind all key numbers to tags.
|
||||||
-- Be careful: we use keycodes to make it work on any keyboard layout.
|
-- Be careful: we use keycodes to make it work on any keyboard layout.
|
||||||
-- This should map on the top row of your keyboard, usually 1 to 9.
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
||||||
for i = 1, 9 do
|
-- for i = 1, 9 do
|
||||||
hotkey.registerKeys(-- View tag only.
|
-- hotkey.registerKeys(-- View tag only.
|
||||||
awful.key({ config.keys.modkey }, "#" .. i + 9,
|
-- awful.key({ config.keys.modkey }, "#" .. i + 9,
|
||||||
function()
|
-- function()
|
||||||
local screen = awful.screen.focused()
|
-- local screen = awful.screen.focused()
|
||||||
local tag = screen.tags[i]
|
-- local tag = screen.tags[i]
|
||||||
if tag then
|
-- if tag then
|
||||||
tag:view_only()
|
-- tag:view_only()
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
{ description = "view tag #" .. i, group = "tag" }),
|
-- { description = "view tag #" .. i, group = "tag" }),
|
||||||
-- Toggle tag display.
|
-- -- Toggle tag display.
|
||||||
awful.key({ config.keys.modkey, "Control" }, "#" .. i + 9,
|
-- awful.key({ config.keys.modkey, "Control" }, "#" .. i + 9,
|
||||||
function()
|
-- function()
|
||||||
local screen = awful.screen.focused()
|
-- local screen = awful.screen.focused()
|
||||||
local tag = screen.tags[i]
|
-- local tag = screen.tags[i]
|
||||||
if tag then
|
-- if tag then
|
||||||
awful.tag.viewtoggle(tag)
|
-- awful.tag.viewtoggle(tag)
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
{ description = "toggle tag #" .. i, group = "tag" }),
|
-- { description = "toggle tag #" .. i, group = "tag" }),
|
||||||
-- Move client to tag.
|
-- -- Move client to tag.
|
||||||
awful.key({ config.keys.modkey, "Shift" }, "#" .. i + 9,
|
-- awful.key({ config.keys.modkey, "Shift" }, "#" .. i + 9,
|
||||||
function()
|
-- function()
|
||||||
if client.focus then
|
-- if client.focus then
|
||||||
local tag = client.focus.screen.tags[i]
|
-- local tag = client.focus.screen.tags[i]
|
||||||
if tag then
|
-- if tag then
|
||||||
client.focus:move_to_tag(tag)
|
-- client.focus:move_to_tag(tag)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
{ description = "move focused client to tag #" .. i, group = "tag" }),
|
-- { description = "move focused client to tag #" .. i, group = "tag" }),
|
||||||
-- Toggle tag on focused client.
|
-- -- Toggle tag on focused client.
|
||||||
awful.key({ config.keys.modkey, "Control", "Shift" }, "#" .. i + 9,
|
-- awful.key({ config.keys.modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||||
function()
|
-- function()
|
||||||
if client.focus then
|
-- if client.focus then
|
||||||
local tag = client.focus.screen.tags[i]
|
-- local tag = client.focus.screen.tags[i]
|
||||||
if tag then
|
-- if tag then
|
||||||
client.focus:toggle_tag(tag)
|
-- client.focus:toggle_tag(tag)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
{ description = "toggle focused client on tag #" .. i, group = "tag" }))
|
-- { description = "toggle focused client on tag #" .. i, group = "tag" }))
|
||||||
end
|
-- end
|
||||||
|
|
||||||
clientbuttons = gears.table.join(awful.button({}, 1, function(c)
|
clientbuttons = gears.table.join(awful.button({}, 1, function(c)
|
||||||
c:emit_signal("request::activate", "mouse_click", { raise = true })
|
c:emit_signal("request::activate", "mouse_click", { raise = true })
|
||||||
@ -669,7 +674,7 @@ awful.rules.rules = {
|
|||||||
rule_any = {
|
rule_any = {
|
||||||
type = { "normal", "dialog" }
|
type = { "normal", "dialog" }
|
||||||
},
|
},
|
||||||
properties = { titlebars_enabled = true }
|
properties = { titlebars_enabled = false }
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Set Firefox to always map on the tag named "2" on screen 1.
|
-- Set Firefox to always map on the tag named "2" on screen 1.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
local awful = require("awful")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
@ -50,6 +51,13 @@ function readCommand(command)
|
|||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function readFile(file)
|
||||||
|
local handle = io.open(file, "r")
|
||||||
|
local r = handle:read("*a")
|
||||||
|
handle:close()
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local cpuBar = bars:get_children()[1]:get_children()[1]:get_children()[1]
|
local cpuBar = bars:get_children()[1]:get_children()[1]:get_children()[1]
|
||||||
function getCpuData()
|
function getCpuData()
|
||||||
@ -131,72 +139,106 @@ gears.timer {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
local battery = wibox.widget {
|
--- Batteries
|
||||||
{
|
---
|
||||||
markup = "-- %",
|
rawBatteries = {}
|
||||||
align = "center",
|
function refreshRawBatteries()
|
||||||
valign = "center",
|
rawBatteries = readCommand("ls -A1 /sys/class/power_supply")
|
||||||
widget = wibox.widget.textbox,
|
|
||||||
},
|
|
||||||
margins = beautiful.system_resources_widget_battery_margin,
|
|
||||||
widget = wibox.container.margin,
|
|
||||||
}
|
|
||||||
|
|
||||||
local batteryText = battery:get_children()[1]
|
|
||||||
|
|
||||||
local rawBatteries = readCommand("ls -A1 /sys/class/power_supply")
|
|
||||||
|
|
||||||
function getBatteries()
|
|
||||||
return rawBatteries:gmatch("([^\n]+)")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasBattery()
|
function getBatteryLevel(battery)
|
||||||
return rawBatteries:len() > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function getBatteryCapacity()
|
|
||||||
local charge = 0
|
local charge = 0
|
||||||
local capacity = 0
|
local capacity = 0
|
||||||
for b in getBatteries() do
|
if fileExists(battery .. "/energy_now") then
|
||||||
if b:sub(1,3) ~= 'hid' and readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then
|
charge = charge + readFile(battery .. "/energy_now")
|
||||||
if fileExists("/sys/class/power_supply/" .. b .. "/energy_now") then
|
capacity = capacity + readFile(battery .. "/energy_full")
|
||||||
charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now")
|
elseif fileExists(battery .. "/charge_now") then
|
||||||
capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full")
|
charge = charge + readFile(battery .. "/charge_now")
|
||||||
else
|
capacity = capacity + readFile(battery .. "/charge_full")
|
||||||
charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_now")
|
elseif fileExists(battery .. "/capacity_level") then
|
||||||
capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_full")
|
return readFile(battery .. "/capacity_level")
|
||||||
end
|
else
|
||||||
end
|
return "Unsupported"
|
||||||
end
|
end
|
||||||
return charge / capacity
|
return string.format("%." .. config.battery.precision .. "f", (charge / capacity) * 100) .. "%"
|
||||||
end
|
end
|
||||||
|
|
||||||
function isCharging()
|
function isCharging(battery)
|
||||||
for b in getBatteries() do
|
return readFile(battery .. "/status") == "Charging\n"
|
||||||
if readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then
|
end
|
||||||
return readCommand("cat /sys/class/power_supply/" .. b .. "/status") ~= "Discharging"
|
|
||||||
end
|
|
||||||
|
local batteryContainer = wibox.widget {
|
||||||
|
layout = wibox.layout.fixed.horizontal
|
||||||
|
}
|
||||||
|
local timers = {}
|
||||||
|
function refreshBatteries()
|
||||||
|
-- refresh raw batteries and check for change
|
||||||
|
local oldBatteries = rawBatteries
|
||||||
|
refreshRawBatteries()
|
||||||
|
if rawBatteries == oldBatteries then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- clear timers
|
||||||
|
for i,v in ipairs(timers) do
|
||||||
|
v:stop()
|
||||||
|
end
|
||||||
|
timers = {};
|
||||||
|
|
||||||
|
-- clear layout
|
||||||
|
batteryContainer:set_children({})
|
||||||
|
|
||||||
|
for battery in rawBatteries:gmatch("([^\n]+)") do
|
||||||
|
local path = "/sys/class/power_supply/" .. battery
|
||||||
|
if readFile(path .. "/type"):match("Battery") then
|
||||||
|
-- widget
|
||||||
|
local widget = wibox.widget {
|
||||||
|
{
|
||||||
|
markup = "-- %",
|
||||||
|
align = "center",
|
||||||
|
valign = "center",
|
||||||
|
widget = wibox.widget.textbox,
|
||||||
|
},
|
||||||
|
margins = beautiful.system_resources_widget_battery_margin,
|
||||||
|
widget = wibox.container.margin,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- tooltip
|
||||||
|
local name = readFile(path .. "/model_name")
|
||||||
|
local tooltip = awful.tooltip {
|
||||||
|
text = name
|
||||||
|
}
|
||||||
|
tooltip:add_to_object(widget)
|
||||||
|
|
||||||
|
-- update battery level
|
||||||
|
local batteryText = widget:get_children()[1]
|
||||||
|
local timer = gears.timer {
|
||||||
|
timeout = config.battery.refresh_interval,
|
||||||
|
call_now = true,
|
||||||
|
autostart = true,
|
||||||
|
callback = function()
|
||||||
|
batteryText.markup = (isCharging(path) and "+" or "") .. getBatteryLevel(path)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
table.insert(timers, timer)
|
||||||
|
|
||||||
|
batteryContainer:add(widget)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
gears.timer {
|
||||||
|
timeout = config.battery.list_refresh_interval,
|
||||||
|
call_now = true,
|
||||||
|
autostart = true,
|
||||||
|
callback = function()
|
||||||
|
refreshBatteries()
|
||||||
end
|
end
|
||||||
return nil
|
}
|
||||||
end
|
|
||||||
|
|
||||||
if hasBattery() then
|
|
||||||
gears.timer {
|
|
||||||
timeout = config.battery.refresh_interval,
|
|
||||||
call_now = true,
|
|
||||||
autostart = true,
|
|
||||||
callback = function()
|
|
||||||
batteryText.markup = string.format("%." .. config.battery.precision .. "f", getBatteryCapacity() * 100) .. "%"
|
|
||||||
end
|
|
||||||
}
|
|
||||||
else
|
|
||||||
battery = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bars = bars,
|
bars = bars,
|
||||||
battery = battery,
|
battery = batteryContainer,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user