forked from ashpie/simple-awesome
Compare commits
19 Commits
ashpie-edi
...
develop
Author | SHA1 | Date | |
---|---|---|---|
b39eac91a5 | |||
2d79eb8a5e | |||
ecbf661115 | |||
00533c13f6 | |||
e36d42dfeb | |||
|
16772da504 | ||
|
7ed0fc7522 | ||
662a816dd0 | |||
957452c55b | |||
6e94e368ed | |||
fbc13ab63f | |||
5961d734b5 | |||
93a3caf5a4 | |||
4b93a05fa5 | |||
c8409703e1 | |||
3908cb4058 | |||
f3b9ffcaf9 | |||
37a94eb5ed | |||
e3cbb2f987 |
@ -28,10 +28,11 @@ By default, Simple Awesome uses
|
||||
- Replace the os menu with a custom widget
|
||||
- Add backlight media keys to xbacklight command functionnality
|
||||
- Add icon to the battery widget
|
||||
- Make mouse auto focus configurable
|
||||
- Make desktop entries menu
|
||||
- Alt tab tab tab to switch
|
||||
|
||||
## Arisu personal todo
|
||||
## Interesting resources
|
||||
|
||||
- https://github.com/manilarome/the-glorious-dotfiles/tree/master/config/awesome/gnawesome/module
|
||||
|
||||
## ashpie personal todo
|
||||
|
||||
- Add aliases to rofi https://github.com/davatorium/rofi/issues/97
|
||||
|
1
assets/icons/hibernate.svg
Normal file
1
assets/icons/hibernate.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-save"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path><polyline points="17 21 17 13 7 13 7 21"></polyline><polyline points="7 3 7 8 15 8"></polyline></svg>
|
After Width: | Height: | Size: 392 B |
1
assets/icons/sleep.svg
Normal file
1
assets/icons/sleep.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-pause"><rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect></svg>
|
After Width: | Height: | Size: 312 B |
@ -25,7 +25,7 @@ config.awesome = {
|
||||
application_launcher_cmd = "rofi -show run -config " .. awful.util.getdir("config") .. "/assets/rofi/themes/paper-float.rasi",
|
||||
|
||||
-- Screen locker
|
||||
lock_command = "i3lock --blur=5 -f -k --timecolor=ffffffff --datecolor=ffffffff --indicator --ringcolor=aaaaaaaa",
|
||||
lock_command = "i3lock --blur=5 -f -k --time-color=ffffffff --date-color=ffffffff --indicator --ring-color=aaaaaaaa",
|
||||
-- lock_command = "xscreensaver-command -lock",
|
||||
|
||||
-- Terminal
|
||||
@ -171,7 +171,8 @@ config.widgets = {
|
||||
battery = {
|
||||
enabled = true,
|
||||
screens = { 1, 2 },
|
||||
refresh_interval = 30, -- In seconds
|
||||
refresh_interval = 15, -- In seconds
|
||||
list_refresh_interval = 2, -- In seconds
|
||||
precision = 0, -- How many decimals
|
||||
},
|
||||
},
|
||||
|
@ -187,6 +187,7 @@ theme.volume_osd_border_color = theme.border_normal
|
||||
theme.volume_osd_border_width = dpi(0)
|
||||
theme.volume_osd_progress_bg = theme.bg_minimize
|
||||
theme.volume_osd_progress_color = "#ffffff"
|
||||
theme.volume_osd_progress_color_muted = "#555555"
|
||||
theme.volume_osd_progress_border_color = theme.volume_osd_border_color
|
||||
theme.volume_osd_progress_border_width = dpi(0)
|
||||
theme.volume_osd_image_color = "#ffffff"
|
||||
|
2
rc.lua
2
rc.lua
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Simple Awesome - By Arisu & Arkhist
|
||||
-- Simple Awesome - By ashpie & Arkhist
|
||||
-- To configure Simple Awesome without losing your changes when updating, see the `config.lua` file.
|
||||
--
|
||||
require("simple")
|
||||
|
@ -168,10 +168,12 @@ local launcher = awful.widget.button({
|
||||
launcher:buttons(gears.table.join(launcher:buttons(),
|
||||
awful.button({}, 1, nil, function() showAppLauncher(false) end)))
|
||||
|
||||
shutdown_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/power.svg", beautiful.power_menu_icon_color)
|
||||
restart_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/refresh-cw.svg", beautiful.power_menu_icon_color)
|
||||
logout_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/log-out.svg", beautiful.power_menu_icon_color)
|
||||
lock_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/lock.svg", beautiful.power_menu_icon_color)
|
||||
logout_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/log-out.svg", beautiful.power_menu_icon_color)
|
||||
sleep_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/sleep.svg", beautiful.power_menu_icon_color)
|
||||
hibernate_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/hibernate.svg", beautiful.power_menu_icon_color)
|
||||
restart_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/refresh-cw.svg", beautiful.power_menu_icon_color)
|
||||
shutdown_icon = gears.color.recolor_image(awful.util.getdir("config") .. "/assets/icons/power.svg", beautiful.power_menu_icon_color)
|
||||
|
||||
os_menu = awful.widget.launcher({
|
||||
image = beautiful.awesome_icon,
|
||||
@ -183,6 +185,9 @@ os_menu = awful.widget.launcher({
|
||||
{ "Open terminal", config.awesome.terminal },
|
||||
{ "Lock", lockScreen, lock_icon },
|
||||
{ "Logout", function() awesome.quit() end, logout_icon },
|
||||
{ "Sleep", function() os.execute('systemctl suspend') end, sleep_icon},
|
||||
{ "Hybrid sleep", function() os.execute('systemctl hybrid-sleep') end, hibernate_icon },
|
||||
{ "Hibernate", function() os.execute('systemctl hibernate') end, hibernate_icon },
|
||||
{ "Restart", function() os.execute('shutdown -r now') end, restart_icon },
|
||||
{ "Shutdown", function() os.execute('shutdown now') end, shutdown_icon },
|
||||
}
|
||||
@ -237,7 +242,7 @@ local function set_wallpaper(s)
|
||||
if type(wallpaper) == "function" then
|
||||
wallpaper = wallpaper(s)
|
||||
end
|
||||
gears.wallpaper.maximized(wallpaper, s, true)
|
||||
gears.wallpaper.maximized(wallpaper, s)
|
||||
end
|
||||
end
|
||||
|
||||
@ -495,7 +500,7 @@ clientkeys = gears.table.join(-- tiling
|
||||
{ description = "toggle fullscreen", group = "client" }),
|
||||
awful.key({ config.keys.modkey, "Shift" }, "c", function(c) c:kill() end,
|
||||
{ description = "close", group = "client" }),
|
||||
awful.key({ config.keys.modkey, "Control" }, "space", awful.client.floating.toggle,
|
||||
awful.key({ config.keys.modkey, "Shift" }, "space", awful.client.floating.toggle,
|
||||
{ description = "toggle floating", group = "client" }),
|
||||
awful.key({ config.keys.modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end,
|
||||
{ description = "move to master", group = "client" }),
|
||||
@ -527,7 +532,16 @@ clientkeys = gears.table.join(-- tiling
|
||||
c.maximized_horizontal = not c.maximized_horizontal
|
||||
c:raise()
|
||||
end,
|
||||
{ description = "(un)maximize horizontally", group = "client" }))
|
||||
{ description = "(un)maximize horizontally", group = "client" }),
|
||||
awful.key({ config.keys.modkey, "Shift"}, "p",
|
||||
function(c)
|
||||
awful.titlebar.toggle(c)
|
||||
if c.maximized then
|
||||
c.maximized = false
|
||||
c.maximized = true
|
||||
end
|
||||
end,
|
||||
{ description = "toggle titlebar", group = "client"}))
|
||||
|
||||
-- Bind all key numbers to tags.
|
||||
-- Be careful: we use keycodes to make it work on any keyboard layout.
|
||||
@ -653,7 +667,7 @@ awful.rules.rules = {
|
||||
-- Add titlebars to normal clients and dialogs
|
||||
{
|
||||
rule_any = {
|
||||
type = { "normal" }
|
||||
type = { "normal", "dialog" }
|
||||
},
|
||||
properties = { titlebars_enabled = true }
|
||||
},
|
||||
@ -710,6 +724,10 @@ client.connect_signal("request::titlebars", function(c)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal
|
||||
}
|
||||
|
||||
if c.requests_no_titlebar then
|
||||
awful.titlebar.hide(c)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Enable sloppy focus, so that focus follows mouse.
|
||||
@ -722,3 +740,17 @@ end
|
||||
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)
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Make sure clients requesting fullscreen get a correct fullscreen geometry
|
||||
-- See https://github.com/awesomeWM/awesome/issues/3156
|
||||
-- OP: https://github.com/awesomeWM/awesome/issues/1607#issuecomment-298194491
|
||||
client.connect_signal("property::fullscreen", function(c)
|
||||
if c.fullscreen then
|
||||
gears.timer.delayed_call(function()
|
||||
if c.valid then
|
||||
c:geometry(c.screen.geometry)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -23,46 +23,53 @@ local config = require("config")
|
||||
local hasPlayerctl = os.execute("playerctl -v") == true
|
||||
|
||||
-- playerctl
|
||||
function sendToPlayerctl(command)
|
||||
os.execute("playerctl " .. command)
|
||||
function sendToPlayerctl(command, callback)
|
||||
callback = callback or function()
|
||||
end
|
||||
awful.spawn.easy_async("playerctl " .. command, callback)
|
||||
end
|
||||
|
||||
-- Spotify
|
||||
function sendToSpotify(command)
|
||||
awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command)
|
||||
function sendToSpotify(command, callback)
|
||||
callback = callback or function()
|
||||
end
|
||||
awful.spawn.easy_async_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command, callback)
|
||||
end
|
||||
|
||||
-- Brightness control
|
||||
function getBrightness()
|
||||
local handle = io.popen("xbacklight -get")
|
||||
local brightness = handle:read("*a")
|
||||
handle:close()
|
||||
return brightness
|
||||
function getBrightness(callback)
|
||||
callback = callback or function()
|
||||
end
|
||||
|
||||
function increaseBrightness()
|
||||
os.execute("xbacklight -inc 2")
|
||||
awful.spawn.easy_async("xbacklight -get", function(stdout, stderr, reason, exit_code)
|
||||
callback(stdout)
|
||||
end)
|
||||
end
|
||||
|
||||
function decreaseBrightness()
|
||||
os.execute("xbacklight -dec 2")
|
||||
function increaseBrightness(callback)
|
||||
callback = callback or function()
|
||||
end
|
||||
awful.spawn.easy_async("xbacklight -inc 2", callback)
|
||||
end
|
||||
|
||||
function decreaseBrightness(callback)
|
||||
callback = callback or function()
|
||||
end
|
||||
awful.spawn.easy_async("xbacklight -dec 2", callback)
|
||||
end
|
||||
|
||||
|
||||
-- Volume control
|
||||
function getVolume()
|
||||
if isMuted() then return 0 end
|
||||
local handle = io.popen("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' -M | awk -F\"[][]\" '/%/ { print $2 }' | head -n 1", "r")
|
||||
local volume = string.gsub(handle:read("*a"), "[\n%%]+", "") / 100
|
||||
handle:close()
|
||||
return volume
|
||||
function isMuted(callback)
|
||||
awful.spawn.easy_async_with_shell("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' | egrep 'Playback.*?\\[o' | egrep -o '\\[o.+\\]'", function(stdout, stderr, reason, exit_code)
|
||||
callback(string.match(string.gsub(stdout, "[\n]+", ""), "off"))
|
||||
end)
|
||||
end
|
||||
|
||||
function isMuted()
|
||||
local handle = io.popen("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' | egrep 'Playback.*?\\[o' | egrep -o '\\[o.+\\]'", "r")
|
||||
local muted = string.match(string.gsub(handle:read("*a"), "[\n]+", ""), "off")
|
||||
handle:close()
|
||||
return muted
|
||||
function getVolume(callback)
|
||||
awful.spawn.easy_async_with_shell("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' -M | awk -F\"[][]\" '/%/ { print $2 }' | head -n 1", function(stdout, stderr, reason, exit_code)
|
||||
callback(string.gsub(stdout, "[\n%%]+", "") / 100)
|
||||
end)
|
||||
end
|
||||
|
||||
function getVolumeImage(volume)
|
||||
@ -159,6 +166,18 @@ local previousTrack = function()
|
||||
end
|
||||
|
||||
local displayVolume = function()
|
||||
isMuted(function(muted)
|
||||
getVolume(function(volume)
|
||||
-- Update values
|
||||
imagebox.image = getVolumeImage(muted and 0 or volume)
|
||||
progressbar.value = volume
|
||||
progressbar.color = muted and beautiful.volume_osd_progress_color_muted or beautiful.volume_osd_progress_color
|
||||
|
||||
if timer ~= nil and timer.started then
|
||||
timer:again()
|
||||
return
|
||||
end
|
||||
|
||||
-- Update screen
|
||||
local screen = awful.screen:focused()
|
||||
volumeWibox.screen = screen
|
||||
@ -170,13 +189,6 @@ local displayVolume = function()
|
||||
y = (screen.geometry.y + position[2])
|
||||
})
|
||||
|
||||
-- Get volume
|
||||
local volume = getVolume()
|
||||
|
||||
-- Update values
|
||||
imagebox.image = getVolumeImage(volume)
|
||||
progressbar.value = volume
|
||||
|
||||
-- Show
|
||||
volumeWibox.visible = true
|
||||
|
||||
@ -193,19 +205,25 @@ local displayVolume = function()
|
||||
end
|
||||
}
|
||||
timer:start()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
local raiseVolume = function()
|
||||
os.execute("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' 5%+ -M")
|
||||
awful.spawn.easy_async("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' 5%+ -M", function(stdout, stderr, reason, exit_code)
|
||||
displayVolume()
|
||||
end)
|
||||
end
|
||||
local lowerVolume = function()
|
||||
os.execute("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' 5%- -M")
|
||||
awful.spawn.easy_async("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' 5%- -M", function(stdout, stderr, reason, exit_code)
|
||||
displayVolume()
|
||||
end)
|
||||
end
|
||||
local toggleMute = function()
|
||||
local muted = isMuted()
|
||||
os.execute("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' " .. (muted and 'on' or 'off'))
|
||||
isMuted(function(muted)
|
||||
awful.spawn.easy_async("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' " .. (muted and 'on' or 'off'), function(stdout, stderr, reason, exit_code)
|
||||
displayVolume()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
@ -11,7 +11,7 @@ local layouts = config.widgets.keyboard_layout.layouts
|
||||
local current_layout_index = 1
|
||||
function switchLayout()
|
||||
current_layout_index = (current_layout_index % #(layouts)) + 1
|
||||
os.execute(config.widgets.keyboard_layout.layout_switch_command .. " " .. layouts[current_layout_index])
|
||||
os.execute(config.widgets.keyboard_layout.layout_switch_command .. " \"" .. layouts[current_layout_index] .. "\"")
|
||||
end
|
||||
|
||||
return {
|
||||
|
@ -1,3 +1,4 @@
|
||||
local awful = require("awful")
|
||||
local beautiful = require("beautiful")
|
||||
local gears = require("gears")
|
||||
local naughty = require("naughty")
|
||||
@ -34,6 +35,15 @@ local bars = wibox.widget {
|
||||
layout = wibox.layout.flex.horizontal
|
||||
}
|
||||
|
||||
function fileExists(name)
|
||||
local f = io.open(name, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function readCommand(command)
|
||||
local handle = io.popen(command, "r")
|
||||
local r = handle:read("*a")
|
||||
@ -41,6 +51,13 @@ function readCommand(command)
|
||||
return r
|
||||
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]
|
||||
function getCpuData()
|
||||
@ -122,8 +139,62 @@ gears.timer {
|
||||
|
||||
|
||||
|
||||
---
|
||||
--- Batteries
|
||||
---
|
||||
rawBatteries = {}
|
||||
function refreshRawBatteries()
|
||||
rawBatteries = readCommand("ls -A1 /sys/class/power_supply")
|
||||
end
|
||||
|
||||
local battery = wibox.widget {
|
||||
function getBatteryLevel(battery)
|
||||
local charge = 0
|
||||
local capacity = 0
|
||||
if fileExists(battery .. "/energy_now") then
|
||||
charge = charge + readFile(battery .. "/energy_now")
|
||||
capacity = capacity + readFile(battery .. "/energy_full")
|
||||
elseif fileExists(battery .. "/charge_now") then
|
||||
charge = charge + readFile(battery .. "/charge_now")
|
||||
capacity = capacity + readFile(battery .. "/charge_full")
|
||||
elseif fileExists(battery .. "/capacity_level") then
|
||||
return readFile(battery .. "/capacity_level")
|
||||
else
|
||||
return "Unsupported"
|
||||
end
|
||||
return string.format("%." .. config.battery.precision .. "f", (charge / capacity) * 100) .. "%"
|
||||
end
|
||||
|
||||
function isCharging(battery)
|
||||
return readFile(battery .. "/status") == "Charging\n"
|
||||
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",
|
||||
@ -134,55 +205,40 @@ local battery = wibox.widget {
|
||||
widget = wibox.container.margin,
|
||||
}
|
||||
|
||||
local batteryText = battery:get_children()[1]
|
||||
-- tooltip
|
||||
local name = readFile(path .. "/model_name")
|
||||
local tooltip = awful.tooltip {
|
||||
text = name
|
||||
}
|
||||
tooltip:add_to_object(widget)
|
||||
|
||||
local rawBatteries = readCommand("ls -A1 /sys/class/power_supply")
|
||||
|
||||
function getBatteries()
|
||||
return rawBatteries:gmatch("([^\n]+)")
|
||||
end
|
||||
|
||||
function hasBattery()
|
||||
return rawBatteries:len() > 0
|
||||
end
|
||||
|
||||
function getBatteryCapacity()
|
||||
local charge = 0
|
||||
local capacity = 0
|
||||
for b in getBatteries() do
|
||||
if b:sub(1,3) ~= 'hid' and readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then
|
||||
charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now")
|
||||
capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full")
|
||||
end
|
||||
end
|
||||
return charge / capacity
|
||||
end
|
||||
|
||||
function isCharging()
|
||||
for b in getBatteries() do
|
||||
if readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then
|
||||
return readCommand("cat /sys/class/power_supply/" .. b .. "/status") ~= "Discharging"
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
if hasBattery() then
|
||||
gears.timer {
|
||||
-- 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 = string.format("%." .. config.battery.precision .. "f", getBatteryCapacity() * 100) .. "%"
|
||||
batteryText.markup = (isCharging(path) and "+" or "") .. getBatteryLevel(path)
|
||||
end
|
||||
}
|
||||
else
|
||||
battery = nil
|
||||
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
|
||||
}
|
||||
|
||||
return {
|
||||
bars = bars,
|
||||
battery = battery,
|
||||
battery = batteryContainer,
|
||||
}
|
Loading…
Reference in New Issue
Block a user