Initial commit
|
@ -0,0 +1,94 @@
|
||||||
|
local os = require('os')
|
||||||
|
naughty = require('naughty')
|
||||||
|
local wibox = require('wibox')
|
||||||
|
local awful = require('awful')
|
||||||
|
local gears = require('gears')
|
||||||
|
local json = require('jsonutils')
|
||||||
|
|
||||||
|
local home = os.getenv('HOME')
|
||||||
|
local todo_path = home .. '/.config/todo/todo.json'
|
||||||
|
|
||||||
|
local widget = nil
|
||||||
|
|
||||||
|
function todo_list_widget(index, todo)
|
||||||
|
|
||||||
|
local text = '\n <b>' .. index .. '. ' .. todo.title .. '</b> \n'
|
||||||
|
|
||||||
|
for key, item in pairs(todo.items) do
|
||||||
|
text = text .. ' ' .. key .. '. ' .. item .. ' \n'
|
||||||
|
end
|
||||||
|
|
||||||
|
local text = wibox.widget {
|
||||||
|
markup = text,
|
||||||
|
align = 'left',
|
||||||
|
valign = 'top',
|
||||||
|
font = "Ubuntu 18",
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
}
|
||||||
|
|
||||||
|
local widget = wibox.widget.background(text, todo.color, function(cr, width, height)
|
||||||
|
gears.shape.rounded_rect(cr, width, height, 20)
|
||||||
|
end)
|
||||||
|
|
||||||
|
widget.shape_border_width = 1
|
||||||
|
widget.shape_border_color = "#ffffff"
|
||||||
|
|
||||||
|
return widget
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_background_widget(s)
|
||||||
|
|
||||||
|
local margin = 25
|
||||||
|
|
||||||
|
awful.spawn.easy_async_with_shell(":", function()
|
||||||
|
|
||||||
|
if s.widget ~= nil then
|
||||||
|
s.widget:remove()
|
||||||
|
end
|
||||||
|
|
||||||
|
local f = io.open(todo_path, "rb")
|
||||||
|
|
||||||
|
if f ~= nil then
|
||||||
|
|
||||||
|
local content = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
todo = json.parse(content)
|
||||||
|
|
||||||
|
local l = wibox.layout {
|
||||||
|
homogeneous = false,
|
||||||
|
spacing = margin,
|
||||||
|
forced_num_cols = 3,
|
||||||
|
layout = wibox.layout.grid,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- l:set_orientation('horizontal')
|
||||||
|
|
||||||
|
local widgets = {}
|
||||||
|
|
||||||
|
for key, val in pairs(todo) do
|
||||||
|
l:add(todo_list_widget(key, val))
|
||||||
|
end
|
||||||
|
|
||||||
|
background_widget = awful.wibar({
|
||||||
|
screen = s,
|
||||||
|
height = s.geometry.height,
|
||||||
|
bg = "#00000000",
|
||||||
|
})
|
||||||
|
|
||||||
|
background_widget:setup {
|
||||||
|
wibox.container.margin(l, margin, margin, margin, margin),
|
||||||
|
layout = wibox.layout.manual
|
||||||
|
}
|
||||||
|
|
||||||
|
background_widget:struts({left=0, right=0, top=0, bottom=0})
|
||||||
|
|
||||||
|
s.widget = background_widget
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
-- This function returns a formatted string with the current battery status. It
|
||||||
|
-- can be used to populate a text widget in the awesome window manager. Based
|
||||||
|
-- on the "Gigamo Battery Widget" found in the wiki at awesome.naquadah.org
|
||||||
|
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local naughty = require("naughty")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
local awful = require('awful')
|
||||||
|
local su = require('su')
|
||||||
|
|
||||||
|
local previous_percent = 0
|
||||||
|
|
||||||
|
function batteryInfo(callback)
|
||||||
|
awful.spawn.easy_async('acpi', function(stdout)
|
||||||
|
-- Consider only the first line
|
||||||
|
local line = su.split(stdout, '\n')[1]
|
||||||
|
|
||||||
|
local split = su.split(line, ':')
|
||||||
|
|
||||||
|
-- Extract the percentage from the string
|
||||||
|
local percent = tonumber(su.split(split[2],',')[2]:sub(1, -2))
|
||||||
|
|
||||||
|
-- callback(percent, isCharging)
|
||||||
|
callback(tonumber(percent), not string.find(line, 'Discharging'))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_battery()
|
||||||
|
|
||||||
|
batteryInfo(function(percent, isCharging)
|
||||||
|
|
||||||
|
local color
|
||||||
|
local symbol
|
||||||
|
|
||||||
|
if percent < 15 then
|
||||||
|
color="red"
|
||||||
|
elseif percent < 30 then
|
||||||
|
color="orange"
|
||||||
|
elseif percent > 90 then
|
||||||
|
color="green"
|
||||||
|
else
|
||||||
|
color="white"
|
||||||
|
end
|
||||||
|
|
||||||
|
if isCharging then
|
||||||
|
color = 'green'
|
||||||
|
symbol = '⚡'
|
||||||
|
else
|
||||||
|
symbol = '%'
|
||||||
|
end
|
||||||
|
|
||||||
|
if previous_percent >= 15 and percent < 15 then
|
||||||
|
naughty.notify({
|
||||||
|
title = "Low battery...",
|
||||||
|
text = "Battery level is lower than 15% !",
|
||||||
|
fg="#000000",
|
||||||
|
bg="#ff0000",
|
||||||
|
timeout=5
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
battery_widget:set_markup('<span color="' .. color .. '">' .. percent .. ' ' .. symbol .. '</span>')
|
||||||
|
|
||||||
|
previous_percent = percent
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
battery_widget = wibox.widget.textbox()
|
||||||
|
battery_widget.timer = timer({timeout=5})
|
||||||
|
battery_widget.timer:connect_signal("timeout", update_battery)
|
||||||
|
battery_widget.timer:start()
|
||||||
|
update_battery()
|
|
@ -0,0 +1,8 @@
|
||||||
|
local awful = require("awful")
|
||||||
|
|
||||||
|
textclock_widget = awful.widget.textclock(" %a %d %b %H:%M ")
|
||||||
|
|
||||||
|
calendar_widget = awful.tooltip({objects={textclock_widget}})
|
||||||
|
awful.spawn.easy_async('gcal -i- -s1 .+', function(stdout)
|
||||||
|
calendar_widget:set_text(stdout)
|
||||||
|
end)
|
|
@ -0,0 +1,43 @@
|
||||||
|
-- INSPIRED FROM
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
-- @author Julien Danjou <julien@danjou.info>
|
||||||
|
-- @copyright 2008-2009 Julien Danjou
|
||||||
|
-- @classmod awful.widget.launcher
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
-- MODIFIED BY
|
||||||
|
-- thomas forgione
|
||||||
|
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local naughty = require('naughty')
|
||||||
|
local gtable = require("gears.table")
|
||||||
|
local spawn = require("awful.spawn")
|
||||||
|
local wbutton = require("awful.widget.button")
|
||||||
|
local button = require("awful.button")
|
||||||
|
|
||||||
|
local launcher = { mt = {} }
|
||||||
|
|
||||||
|
--- Create a button widget which will launch a command.
|
||||||
|
-- @param args Standard widget table arguments, plus image for the image path
|
||||||
|
-- and command for the command to run on click, or either menu to create menu.
|
||||||
|
-- @return A launcher widget.
|
||||||
|
function launcher.new(args)
|
||||||
|
if not args.callback and not args.menu then return end
|
||||||
|
local w = wbutton(args)
|
||||||
|
if not w then return end
|
||||||
|
|
||||||
|
local b
|
||||||
|
if args.callback then
|
||||||
|
b = gtable.join(w:buttons(), button({}, 1, nil, function () args.callback() end))
|
||||||
|
elseif args.menu then
|
||||||
|
b = gtable.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end))
|
||||||
|
end
|
||||||
|
|
||||||
|
w:buttons(b)
|
||||||
|
return w
|
||||||
|
end
|
||||||
|
|
||||||
|
function launcher.mt:__call(...)
|
||||||
|
return launcher.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(launcher, launcher.mt)
|
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 74 KiB |
|
@ -0,0 +1,199 @@
|
||||||
|
--[[ json.lua
|
||||||
|
|
||||||
|
Downloaded from: https://gist.github.com/tylerneylon/59f4bcf316be525b30ab
|
||||||
|
Owner said:
|
||||||
|
> Oh hey @Shujito and @S0lll0s, sorry for the delayed response.
|
||||||
|
> Yes, please use it. I put this in the public domain.
|
||||||
|
|
||||||
|
A compact pure-Lua JSON library.
|
||||||
|
The main functions are: json.stringify, json.parse.
|
||||||
|
|
||||||
|
## json.stringify:
|
||||||
|
|
||||||
|
This expects the following to be true of any tables being encoded:
|
||||||
|
* They only have string or number keys. Number keys must be represented as
|
||||||
|
strings in json; this is part of the json spec.
|
||||||
|
* They are not recursive. Such a structure cannot be specified in json.
|
||||||
|
|
||||||
|
A Lua table is considered to be an array if and only if its set of keys is a
|
||||||
|
consecutive sequence of positive integers starting at 1. Arrays are encoded like
|
||||||
|
so: `[2, 3, false, "hi"]`. Any other type of Lua table is encoded as a json
|
||||||
|
object, encoded like so: `{"key1": 2, "key2": false}`.
|
||||||
|
|
||||||
|
Because the Lua nil value cannot be a key, and as a table value is considerd
|
||||||
|
equivalent to a missing key, there is no way to express the json "null" value in
|
||||||
|
a Lua table. The only way this will output "null" is if your entire input obj is
|
||||||
|
nil itself.
|
||||||
|
|
||||||
|
An empty Lua table, {}, could be considered either a json object or array -
|
||||||
|
it's an ambiguous edge case. We choose to treat this as an object as it is the
|
||||||
|
more general type.
|
||||||
|
|
||||||
|
To be clear, none of the above considerations is a limitation of this code.
|
||||||
|
Rather, it is what we get when we completely observe the json specification for
|
||||||
|
as arbitrary a Lua object as json is capable of expressing.
|
||||||
|
|
||||||
|
## json.parse:
|
||||||
|
|
||||||
|
This function parses json, with the exception that it does not pay attention to
|
||||||
|
\u-escaped unicode code points in strings.
|
||||||
|
|
||||||
|
It is difficult for Lua to return null as a value. In order to prevent the loss
|
||||||
|
of keys with a null value in a json string, this function uses the one-off
|
||||||
|
table value json.null (which is just an empty table) to indicate null values.
|
||||||
|
This way you can check if a value is null with the conditional
|
||||||
|
`val == json.null`.
|
||||||
|
|
||||||
|
If you have control over the data and are using Lua, I would recommend just
|
||||||
|
avoiding null values in your data to begin with.
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
local json = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- Internal functions.
|
||||||
|
|
||||||
|
local function kind_of(obj)
|
||||||
|
if type(obj) ~= 'table' then return type(obj) end
|
||||||
|
local i = 1
|
||||||
|
for _ in pairs(obj) do
|
||||||
|
if obj[i] ~= nil then i = i + 1 else return 'table' end
|
||||||
|
end
|
||||||
|
if i == 1 then return 'table' else return 'array' end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function escape_str(s)
|
||||||
|
local in_char = {'\\', '"', '/', '\b', '\f', '\n', '\r', '\t'}
|
||||||
|
local out_char = {'\\', '"', '/', 'b', 'f', 'n', 'r', 't'}
|
||||||
|
for i, c in ipairs(in_char) do
|
||||||
|
s = s:gsub(c, '\\' .. out_char[i])
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns pos, did_find; there are two cases:
|
||||||
|
-- 1. Delimiter found: pos = pos after leading space + delim; did_find = true.
|
||||||
|
-- 2. Delimiter not found: pos = pos after leading space; did_find = false.
|
||||||
|
-- This throws an error if err_if_missing is true and the delim is not found.
|
||||||
|
local function skip_delim(str, pos, delim, err_if_missing)
|
||||||
|
pos = pos + #str:match('^%s*', pos)
|
||||||
|
if str:sub(pos, pos) ~= delim then
|
||||||
|
if err_if_missing then
|
||||||
|
error('Expected ' .. delim .. ' near position ' .. pos)
|
||||||
|
end
|
||||||
|
return pos, false
|
||||||
|
end
|
||||||
|
return pos + 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Expects the given pos to be the first character after the opening quote.
|
||||||
|
-- Returns val, pos; the returned pos is after the closing quote character.
|
||||||
|
local function parse_str_val(str, pos, val)
|
||||||
|
val = val or ''
|
||||||
|
local early_end_error = 'End of input found while parsing string.'
|
||||||
|
if pos > #str then error(early_end_error) end
|
||||||
|
local c = str:sub(pos, pos)
|
||||||
|
if c == '"' then return val, pos + 1 end
|
||||||
|
if c ~= '\\' then return parse_str_val(str, pos + 1, val .. c) end
|
||||||
|
-- We must have a \ character.
|
||||||
|
local esc_map = {b = '\b', f = '\f', n = '\n', r = '\r', t = '\t'}
|
||||||
|
local nextc = str:sub(pos + 1, pos + 1)
|
||||||
|
if not nextc then error(early_end_error) end
|
||||||
|
return parse_str_val(str, pos + 2, val .. (esc_map[nextc] or nextc))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns val, pos; the returned pos is after the number's final character.
|
||||||
|
local function parse_num_val(str, pos)
|
||||||
|
local num_str = str:match('^-?%d+%.?%d*[eE]?[+-]?%d*', pos)
|
||||||
|
local val = tonumber(num_str)
|
||||||
|
if not val then error('Error parsing number at position ' .. pos .. '.') end
|
||||||
|
return val, pos + #num_str
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Public values and functions.
|
||||||
|
|
||||||
|
function json.stringify(obj, as_key)
|
||||||
|
local s = {} -- We'll build the string as an array of strings to be concatenated.
|
||||||
|
local kind = kind_of(obj) -- This is 'array' if it's an array or type(obj) otherwise.
|
||||||
|
if kind == 'array' then
|
||||||
|
if as_key then error('Can\'t encode array as key.') end
|
||||||
|
s[#s + 1] = '['
|
||||||
|
for i, val in ipairs(obj) do
|
||||||
|
if i > 1 then s[#s + 1] = ', ' end
|
||||||
|
s[#s + 1] = json.stringify(val)
|
||||||
|
end
|
||||||
|
s[#s + 1] = ']'
|
||||||
|
elseif kind == 'table' then
|
||||||
|
if as_key then error('Can\'t encode table as key.') end
|
||||||
|
s[#s + 1] = '{'
|
||||||
|
for k, v in pairs(obj) do
|
||||||
|
if #s > 1 then s[#s + 1] = ', ' end
|
||||||
|
s[#s + 1] = json.stringify(k, true)
|
||||||
|
s[#s + 1] = ':'
|
||||||
|
s[#s + 1] = json.stringify(v)
|
||||||
|
end
|
||||||
|
s[#s + 1] = '}'
|
||||||
|
elseif kind == 'string' then
|
||||||
|
return '"' .. escape_str(obj) .. '"'
|
||||||
|
elseif kind == 'number' then
|
||||||
|
if as_key then return '"' .. tostring(obj) .. '"' end
|
||||||
|
return tostring(obj)
|
||||||
|
elseif kind == 'boolean' then
|
||||||
|
return tostring(obj)
|
||||||
|
elseif kind == 'nil' then
|
||||||
|
return 'null'
|
||||||
|
else
|
||||||
|
error('Unjsonifiable type: ' .. kind .. '.')
|
||||||
|
end
|
||||||
|
return table.concat(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
json.null = {} -- This is a one-off table to represent the null value.
|
||||||
|
|
||||||
|
function json.parse(str, pos, end_delim)
|
||||||
|
pos = pos or 1
|
||||||
|
if pos > #str then error('Reached unexpected end of input.') end
|
||||||
|
local pos = pos + #str:match('^%s*', pos) -- Skip whitespace.
|
||||||
|
local first = str:sub(pos, pos)
|
||||||
|
if first == '{' then -- Parse an object.
|
||||||
|
local obj, key, delim_found = {}, true, true
|
||||||
|
pos = pos + 1
|
||||||
|
while true do
|
||||||
|
key, pos = json.parse(str, pos, '}')
|
||||||
|
if key == nil then return obj, pos end
|
||||||
|
if not delim_found then error('Comma missing between object items.') end
|
||||||
|
pos = skip_delim(str, pos, ':', true) -- true -> error if missing.
|
||||||
|
obj[key], pos = json.parse(str, pos)
|
||||||
|
pos, delim_found = skip_delim(str, pos, ',')
|
||||||
|
end
|
||||||
|
elseif first == '[' then -- Parse an array.
|
||||||
|
local arr, val, delim_found = {}, true, true
|
||||||
|
pos = pos + 1
|
||||||
|
while true do
|
||||||
|
val, pos = json.parse(str, pos, ']')
|
||||||
|
if val == nil then return arr, pos end
|
||||||
|
if not delim_found then error('Comma missing between array items.') end
|
||||||
|
arr[#arr + 1] = val
|
||||||
|
pos, delim_found = skip_delim(str, pos, ',')
|
||||||
|
end
|
||||||
|
elseif first == '"' then -- Parse a string.
|
||||||
|
return parse_str_val(str, pos + 1)
|
||||||
|
elseif first == '-' or first:match('%d') then -- Parse a number.
|
||||||
|
return parse_num_val(str, pos)
|
||||||
|
elseif first == end_delim then -- End of an object or array.
|
||||||
|
return nil, pos + 1
|
||||||
|
else -- Parse true, false, or null.
|
||||||
|
local literals = {['true'] = true, ['false'] = false, ['null'] = json.null}
|
||||||
|
for lit_str, lit_val in pairs(literals) do
|
||||||
|
local lit_end = pos + #lit_str - 1
|
||||||
|
if str:sub(pos, lit_end) == lit_str then return lit_val, lit_end + 1 end
|
||||||
|
end
|
||||||
|
local pos_info_str = 'position ' .. pos .. ': ' .. str:sub(pos, pos + 10)
|
||||||
|
error('Invalid json syntax starting at ' .. pos_info_str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return json
|
|
@ -0,0 +1,68 @@
|
||||||
|
-- Quick launchbar widget for Awesome WM
|
||||||
|
-- http://awesome.naquadah.org/wiki/Quick_launch_bar_widget/3.5
|
||||||
|
-- Put into your awesome/ folder and add the following to rc.lua:
|
||||||
|
-- local launchbar = require('launchbar')
|
||||||
|
-- local mylb = launchbar("/path/to/directory/with/shortcuts/")
|
||||||
|
-- Then add mylb to the wibox.
|
||||||
|
|
||||||
|
local naughty = require('naughty')
|
||||||
|
local layout = require("wibox.layout")
|
||||||
|
local util = require("awful.util")
|
||||||
|
local spawn = require('awful.spawn')
|
||||||
|
local launcher = require("command_launcher")
|
||||||
|
|
||||||
|
local launchbar = {}
|
||||||
|
|
||||||
|
local function getValue(t, key)
|
||||||
|
local _, _, res = string.find(t, key .. " *= *([^%c]+)%c")
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
|
local function find_icon(icon_name)
|
||||||
|
if string.sub(icon_name, 1, 1) == '/' then
|
||||||
|
if util.file_readable(icon_name) then
|
||||||
|
return icon_name
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if launchbar.icon_dirs then
|
||||||
|
for _, v in ipairs(launchbar.icon_dirs) do
|
||||||
|
if util.file_readable(v .. "/" .. icon_name) then
|
||||||
|
return v .. '/' .. icon_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function launchbar.new(filedir)
|
||||||
|
if not filedir then
|
||||||
|
error("Launchbar: filedir was not specified")
|
||||||
|
end
|
||||||
|
local items = {}
|
||||||
|
local widget = layout.fixed.horizontal()
|
||||||
|
local files = io.popen("ls " .. filedir .. "*.desktop")
|
||||||
|
for f in files:lines() do
|
||||||
|
local t = io.open(f):read("*all")
|
||||||
|
table.insert(items, { image = find_icon(getValue(t,"Icon")),
|
||||||
|
callback = function ()
|
||||||
|
naughty.notify({
|
||||||
|
title = "Starting " .. getValue(t, "Name"),
|
||||||
|
text = ""
|
||||||
|
})
|
||||||
|
spawn(getValue(t,"Exec"))
|
||||||
|
end,
|
||||||
|
position = tonumber(getValue(t,"Position")) or 255 })
|
||||||
|
end
|
||||||
|
table.sort(items, function(a,b) return a.position < b.position end)
|
||||||
|
for _, v in ipairs(items) do
|
||||||
|
if v.image then
|
||||||
|
widget:add(launcher(v))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return widget
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(launchbar, { __call = function(_, ...) return launchbar.new(...) end })
|
|
@ -0,0 +1,103 @@
|
||||||
|
local naughty = require("naughty")
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
local su = require('su')
|
||||||
|
|
||||||
|
local ret = {}
|
||||||
|
ret.text_widget = wibox.widget.textbox()
|
||||||
|
ret.text_widget:set_align("right")
|
||||||
|
ret.text_widget.font = "Ubuntu Mono"
|
||||||
|
|
||||||
|
ret.icon_widget = wibox.widget.textbox()
|
||||||
|
ret.icon_widget:set_align("right")
|
||||||
|
ret.icon_widget.font = "Ubuntu Mono"
|
||||||
|
|
||||||
|
|
||||||
|
local icon = ""
|
||||||
|
local total_text = ""
|
||||||
|
local position = 1
|
||||||
|
local width = 30
|
||||||
|
local dots = 3
|
||||||
|
|
||||||
|
local function set_text(text)
|
||||||
|
total_text = text
|
||||||
|
|
||||||
|
if string.len(total_text) >= width then
|
||||||
|
position = math.floor((width - string.len(total_text)) / 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function try_noop()
|
||||||
|
|
||||||
|
awful.spawn.easy_async_with_shell('sleep 2s && music-client noop', function(stdout, stderr, reason, code)
|
||||||
|
|
||||||
|
if code == 1 then
|
||||||
|
try_noop()
|
||||||
|
elseif code == 0 then
|
||||||
|
ret.execute_command('noop')
|
||||||
|
end
|
||||||
|
end);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
ret.execute_command = function(command, arg)
|
||||||
|
|
||||||
|
awful.spawn.easy_async({'music-client', command, arg}, function(stdout, stderr, reason, code)
|
||||||
|
|
||||||
|
local text = su.split(stdout, '\n')
|
||||||
|
local active_command =
|
||||||
|
su.starts_with(command, 'file') or
|
||||||
|
su.starts_with(command, 'next') or
|
||||||
|
su.starts_with(command, 'previous')
|
||||||
|
|
||||||
|
local start_server_command = active_command or
|
||||||
|
su.starts_with(command, 'play') or
|
||||||
|
su.starts_with(command, 'pause')
|
||||||
|
|
||||||
|
if code == 0 then
|
||||||
|
|
||||||
|
if active_command then
|
||||||
|
set_text(text[1])
|
||||||
|
elseif su.starts_with(command, 'noop') then
|
||||||
|
total_text = text[1]
|
||||||
|
position = math.floor((width - string.len(total_text)) / 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif start_server_command then
|
||||||
|
-- Start the server and re-exec the command
|
||||||
|
awful.spawn.easy_async({'music-server', 'command', command, arg}, function(stdout, stderr, reason, code)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
set_text('music-server not running')
|
||||||
|
end
|
||||||
|
|
||||||
|
if text[2] ~= nil then
|
||||||
|
icon = text[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_widget()
|
||||||
|
ret.icon_widget:set_text(' ' .. icon .. ' ')
|
||||||
|
if string.len(total_text) < width then
|
||||||
|
ret.text_widget:set_text(' ' .. su.pad(total_text, width + 1, ' '))
|
||||||
|
else
|
||||||
|
local pos = math.min(position, string.len(total_text) - width)
|
||||||
|
pos = math.max(1, pos)
|
||||||
|
ret.text_widget:set_text(' ' .. string.sub(total_text, pos, pos + width))
|
||||||
|
position = position + 1
|
||||||
|
if position > string.len(total_text) then
|
||||||
|
position = math.floor((width - string.len(total_text)) / 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ret.execute_command('noop')
|
||||||
|
|
||||||
|
ret.timer = timer({timeout=0.2})
|
||||||
|
ret.timer:connect_signal("timeout", update_widget)
|
||||||
|
ret.timer:start()
|
||||||
|
|
||||||
|
return ret
|
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
browser="firefox",
|
||||||
|
terminal="terminator",
|
||||||
|
email="thomas@forgione.fr",
|
||||||
|
}
|
|
@ -0,0 +1,715 @@
|
||||||
|
local os = require('os')
|
||||||
|
local math = require('math')
|
||||||
|
|
||||||
|
-- Standard awesome library
|
||||||
|
local gears = require("gears")
|
||||||
|
local awful = require("awful")
|
||||||
|
require("awful.autofocus")
|
||||||
|
-- Widget and layout library
|
||||||
|
local wibox = require("wibox")
|
||||||
|
-- Theme handling library
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
-- Notification library
|
||||||
|
local naughty = require("naughty")
|
||||||
|
local menubar = require("menubar")
|
||||||
|
local hotkeys_popup = require("awful.hotkeys_popup").widget
|
||||||
|
|
||||||
|
-- Custom imports
|
||||||
|
local options = require("options")
|
||||||
|
home = os.getenv('HOME')
|
||||||
|
|
||||||
|
os.execute('xset m 16/1 0')
|
||||||
|
os.setlocale("fr_FR.UTF-8")
|
||||||
|
|
||||||
|
-- Run xsession if exists
|
||||||
|
function file_exists(name)
|
||||||
|
local f=io.open(name,"r")
|
||||||
|
if f~=nil then io.close(f) return true else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
if file_exists(home..'/.xsession') then
|
||||||
|
os.execute(home .. '/.xsession &')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
naughty.config.notify_callback = function(args)
|
||||||
|
-- Set maximum size for notifactions
|
||||||
|
if args.icon_size == nil or args.icon_size > 128 then
|
||||||
|
args.icon_size = 128
|
||||||
|
end
|
||||||
|
return args
|
||||||
|
end
|
||||||
|
-- awful.util.spawn_with_shell("xcompmgr -cF &")
|
||||||
|
|
||||||
|
naughty.config.presets.normal.bg = "#000000"
|
||||||
|
-- naughty.config.presets.normal.width = 300
|
||||||
|
-- naughty.config.presets.normal.height = 100
|
||||||
|
naughty.config.presets.normal.font = "Ubuntu 12pt"
|
||||||
|
naughty.config.presets.normal.opacity = 0.7
|
||||||
|
|
||||||
|
naughty.config.presets.low.opacity = 0.7
|
||||||
|
naughty.config.presets.critical.opacity = 0.7
|
||||||
|
naughty.config.presets.critical.font = "Ubuntu 12pt"
|
||||||
|
naughty.config.presets.critical.timeout = 5
|
||||||
|
naughty.config.presets.critical.bg = "#111111"
|
||||||
|
naughty.config.presets.critical.fg = "#aaaaaa"
|
||||||
|
|
||||||
|
-- {{{ Error handling
|
||||||
|
-- Check if awesome encountered an error during startup and fell back to
|
||||||
|
-- another config (This code will only ever execute for the fallback config)
|
||||||
|
if awesome.startup_errors then
|
||||||
|
naughty.notify({ preset = naughty.config.presets.critical,
|
||||||
|
title = "Oops, there were errors during startup!",
|
||||||
|
text = awesome.startup_errors })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Handle runtime errors after startup
|
||||||
|
do
|
||||||
|
local in_error = false
|
||||||
|
awesome.connect_signal("debug::error", function (err)
|
||||||
|
-- Make sure we don't go into an endless error loop
|
||||||
|
if in_error then return end
|
||||||
|
in_error = true
|
||||||
|
|
||||||
|
naughty.notify({ preset = naughty.config.presets.critical,
|
||||||
|
title = "Oops, an error happened!",
|
||||||
|
text = tostring(err) })
|
||||||
|
in_error = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Variable definitions
|
||||||
|
-- Themes define colours, icons, font and wallpapers.
|
||||||
|
beautiful.init("~/.config/awesome/themes/default/theme.lua")
|
||||||
|
|
||||||
|
-- This is used later as the default terminal and editor to run.
|
||||||
|
terminal = options.terminal
|
||||||
|
editor = os.getenv("EDITOR") or "nano"
|
||||||
|
editor_cmd = terminal .. " -e " .. editor
|
||||||
|
|
||||||
|
-- Default modkey.
|
||||||
|
-- Usually, Mod4 is the key with a logo between Control and Alt.
|
||||||
|
-- If you do not like this or do not have such a key,
|
||||||
|
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
|
||||||
|
-- However, you can use another modifier like Mod1, but it may interact with others.
|
||||||
|
modkey = "Mod4"
|
||||||
|
|
||||||
|
-- Table of layouts to cover with awful.layout.inc, order matters.
|
||||||
|
awful.layout.layouts = {
|
||||||
|
awful.layout.suit.tile.left,
|
||||||
|
awful.layout.suit.tile,
|
||||||
|
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,
|
||||||
|
awful.layout.suit.floating,
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Helper functions
|
||||||
|
local function client_menu_toggle_fn()
|
||||||
|
local instance = nil
|
||||||
|
|
||||||
|
return function ()
|
||||||
|
if instance and instance.wibox.visible then
|
||||||
|
instance:hide()
|
||||||
|
instance = nil
|
||||||
|
else
|
||||||
|
instance = awful.menu.clients({ theme = { width = 250 } })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Menu
|
||||||
|
-- Create a launcher widget and a main menu
|
||||||
|
myawesomemenu = {
|
||||||
|
{ "hotkeys", function() return false, hotkeys_popup.show_help end},
|
||||||
|
{ "manual", terminal .. " -e man awesome" },
|
||||||
|
{ "edit config", editor_cmd .. " " .. awesome.conffile },
|
||||||
|
{ "restart", awesome.restart },
|
||||||
|
{ "quit", function() awesome.quit() end}
|
||||||
|
}
|
||||||
|
|
||||||
|
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
|
||||||
|
{ "open terminal", terminal }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
|
||||||
|
menu = mymainmenu })
|
||||||
|
|
||||||
|
-- Menubar configuration
|
||||||
|
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Keyboard map indicator and switcher
|
||||||
|
mykeyboardlayout = awful.widget.keyboardlayout()
|
||||||
|
|
||||||
|
-- {{{ Wibar
|
||||||
|
|
||||||
|
-- Create a wibox for each screen and add it
|
||||||
|
local taglist_buttons = awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function(t) t:view_only() end),
|
||||||
|
awful.button({ modkey }, 1, function(t)
|
||||||
|
if client.focus then
|
||||||
|
client.focus:move_to_tag(t)
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.button({ }, 3, awful.tag.viewtoggle),
|
||||||
|
awful.button({ modkey }, 3, function(t)
|
||||||
|
if client.focus then
|
||||||
|
client.focus:toggle_tag(t)
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
|
||||||
|
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
|
||||||
|
)
|
||||||
|
|
||||||
|
local tasklist_buttons = awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function (c)
|
||||||
|
if c == client.focus then
|
||||||
|
c.minimized = true
|
||||||
|
else
|
||||||
|
-- Without this, the following
|
||||||
|
-- :isvisible() makes no sense
|
||||||
|
c.minimized = false
|
||||||
|
if not c:isvisible() and c.first_tag then
|
||||||
|
c.first_tag:view_only()
|
||||||
|
end
|
||||||
|
-- This will also un-minimize
|
||||||
|
-- the client, if needed
|
||||||
|
client.focus = c
|
||||||
|
c:raise()
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
awful.button({ }, 3, client_menu_toggle_fn()),
|
||||||
|
awful.button({ }, 4, function ()
|
||||||
|
awful.client.focus.byidx(1)
|
||||||
|
end),
|
||||||
|
awful.button({ }, 5, function ()
|
||||||
|
awful.client.focus.byidx(-1)
|
||||||
|
end))
|
||||||
|
|
||||||
|
local battery = require('battery')
|
||||||
|
local volume = require('volume')
|
||||||
|
local calendar = require('calendar')
|
||||||
|
local launchbar = require('launchbar')
|
||||||
|
local music = require('music')
|
||||||
|
-- local background = require('background_widget')
|
||||||
|
local delimiter = wibox.widget.textbox(" | ")
|
||||||
|
|
||||||
|
local function set_wallpaper(s)
|
||||||
|
-- Wallpaper
|
||||||
|
if beautiful.wallpaper then
|
||||||
|
local wallpaper = beautiful.wallpaper
|
||||||
|
-- If wallpaper is a function, call it with the screen
|
||||||
|
if type(wallpaper) == "function" then
|
||||||
|
wallpaper = wallpaper(s)
|
||||||
|
end
|
||||||
|
gears.wallpaper.maximized(wallpaper, s, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
|
||||||
|
screen.connect_signal("property::geometry", set_wallpaper)
|
||||||
|
|
||||||
|
awful.screen.connect_for_each_screen(function(s)
|
||||||
|
-- Wallpaper
|
||||||
|
set_wallpaper(s)
|
||||||
|
|
||||||
|
-- Each screen has its own tag table.
|
||||||
|
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[1])
|
||||||
|
|
||||||
|
-- Create a promptbox for each screen
|
||||||
|
s.mypromptbox = awful.widget.prompt()
|
||||||
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
||||||
|
-- We need one layoutbox per screen.
|
||||||
|
s.mylayoutbox = awful.widget.layoutbox(s)
|
||||||
|
s.mylayoutbox:buttons(awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function () awful.layout.inc( 1) end),
|
||||||
|
awful.button({ }, 3, function () awful.layout.inc(-1) end),
|
||||||
|
awful.button({ }, 4, function () awful.layout.inc( 1) end),
|
||||||
|
awful.button({ }, 5, function () awful.layout.inc(-1) end)))
|
||||||
|
-- Create a taglist widget
|
||||||
|
s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
|
||||||
|
|
||||||
|
-- Create a tasklist widget
|
||||||
|
s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
|
||||||
|
|
||||||
|
-- Create the wibox
|
||||||
|
s.mywibox = awful.wibar({ position = "top", screen = s })
|
||||||
|
|
||||||
|
-- Add widgets to the wibox
|
||||||
|
s.mywibox:setup {
|
||||||
|
layout = wibox.layout.align.horizontal,
|
||||||
|
{ -- Left widgets
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
mylauncher,
|
||||||
|
s.mytaglist,
|
||||||
|
launchbar("~/Desktop/"),
|
||||||
|
delimiter,
|
||||||
|
s.mypromptbox,
|
||||||
|
},
|
||||||
|
s.mytasklist, -- Middle widget
|
||||||
|
{ -- Right widgets
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
delimiter,
|
||||||
|
music.icon_widget,
|
||||||
|
music.text_widget,
|
||||||
|
delimiter,
|
||||||
|
volume_widget,
|
||||||
|
delimiter,
|
||||||
|
battery_widget,
|
||||||
|
delimiter,
|
||||||
|
mykeyboardlayout,
|
||||||
|
wibox.widget.systray(),
|
||||||
|
textclock_widget,
|
||||||
|
s.mylayoutbox,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- update_background_widget(s)
|
||||||
|
|
||||||
|
end)
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Mouse bindings
|
||||||
|
root.buttons(awful.util.table.join(
|
||||||
|
awful.button({ }, 3, function () mymainmenu:toggle() end),
|
||||||
|
awful.button({ }, 4, awful.tag.viewnext),
|
||||||
|
awful.button({ }, 5, awful.tag.viewprev)
|
||||||
|
))
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Key bindings
|
||||||
|
globalkeys = awful.util.table.join(
|
||||||
|
awful.key({ modkey, }, "s", hotkeys_popup.show_help,
|
||||||
|
{description="show help", group="awesome"}),
|
||||||
|
awful.key({ modkey, }, "Left", awful.tag.viewprev,
|
||||||
|
{description = "view previous", group = "tag"}),
|
||||||
|
awful.key({ modkey, }, "Right", awful.tag.viewnext,
|
||||||
|
{description = "view next", group = "tag"}),
|
||||||
|
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
|
||||||
|
{description = "go back", group = "tag"}),
|
||||||
|
|
||||||
|
awful.key({ modkey, }, "j",
|
||||||
|
function ()
|
||||||
|
awful.client.focus.byidx( 1)
|
||||||
|
end,
|
||||||
|
{description = "focus next by index", group = "client"}
|
||||||
|
),
|
||||||
|
awful.key({ modkey, }, "k",
|
||||||
|
function ()
|
||||||
|
awful.client.focus.byidx(-1)
|
||||||
|
end,
|
||||||
|
{description = "focus previous by index", group = "client"}
|
||||||
|
),
|
||||||
|
awful.key({ modkey, }, "w", function () mymainmenu:show() end,
|
||||||
|
{description = "show main menu", group = "awesome"}),
|
||||||
|
|
||||||
|
-- Layout manipulation
|
||||||
|
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
|
||||||
|
{description = "swap with next client by index", group = "client"}),
|
||||||
|
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
|
||||||
|
{description = "swap with previous client by index", group = "client"}),
|
||||||
|
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
|
||||||
|
{description = "focus the next screen", group = "screen"}),
|
||||||
|
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
|
||||||
|
{description = "focus the previous screen", group = "screen"}),
|
||||||
|
awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
|
||||||
|
{description = "jump to urgent client", group = "client"}),
|
||||||
|
awful.key({ modkey, }, "Tab",
|
||||||
|
function ()
|
||||||
|
-- awful.client.focus.history.previous()
|
||||||
|
awful.client.focus.byidx(-1)
|
||||||
|
if client.focus then
|
||||||
|
client.focus:raise()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "go back", group = "client"}),
|
||||||
|
-- Standard program
|
||||||
|
awful.key({ modkey, }, "Return", function ()
|
||||||
|
awful.spawn(terminal)
|
||||||
|
naughty.notify({title = "Starting " .. options.terminal})
|
||||||
|
end,
|
||||||
|
{description = "open a terminal", group = "launcher"}),
|
||||||
|
awful.key({ modkey, "Control" }, "r", awesome.restart,
|
||||||
|
{description = "reload awesome", group = "awesome"}),
|
||||||
|
awful.key({ modkey, "Shift" }, "q", awesome.quit,
|
||||||
|
{description = "quit awesome", group = "awesome"}),
|
||||||
|
|
||||||
|
-- awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
|
||||||
|
-- {description = "increase master width factor", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
|
||||||
|
-- {description = "decrease master width factor", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
|
||||||
|
-- {description = "increase the number of master clients", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
|
||||||
|
-- {description = "decrease the number of master clients", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
|
||||||
|
-- {description = "increase the number of columns", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
|
||||||
|
-- {description = "decrease the number of columns", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
|
||||||
|
-- {description = "select next", group = "layout"}),
|
||||||
|
-- awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
|
||||||
|
-- {description = "select previous", group = "layout"}),
|
||||||
|
|
||||||
|
awful.key({ modkey, "Control" }, "n",
|
||||||
|
function ()
|
||||||
|
local c = awful.client.restore()
|
||||||
|
-- Focus restored client
|
||||||
|
if c then
|
||||||
|
client.focus = c
|
||||||
|
c:raise()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "restore minimized", group = "client"}),
|
||||||
|
|
||||||
|
-- Prompt
|
||||||
|
awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
|
||||||
|
{description = "run prompt", group = "launcher"}),
|
||||||
|
|
||||||
|
awful.key({ modkey }, "x",
|
||||||
|
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 = "lua execute prompt", group = "awesome"}),
|
||||||
|
-- Menubar
|
||||||
|
awful.key({ modkey }, "p", function() menubar.show() end,
|
||||||
|
{description = "show the menubar", group = "launcher"}),
|
||||||
|
|
||||||
|
-- Custom shortcuts
|
||||||
|
awful.key({ }, "XF86AudioRaiseVolume", function()
|
||||||
|
awful.util.spawn("amixer set Master 3%+", false)
|
||||||
|
update_volume()
|
||||||
|
end, {description = "increase the volume by 3%", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioLowerVolume", function()
|
||||||
|
awful.util.spawn("amixer set Master 3%-", false)
|
||||||
|
update_volume()
|
||||||
|
end, {description = "decrease the volume by 3%", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioMute", function()
|
||||||
|
awful.util.spawn("amixer set Master toggle", false)
|
||||||
|
update_volume()
|
||||||
|
end, {description = "mute sound", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86MonBrightnessDown", function ()
|
||||||
|
awful.util.spawn("xbacklight -dec 5")
|
||||||
|
end, {description = "decrease brightness", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86MonBrightnessUp", function ()
|
||||||
|
awful.util.spawn("xbacklight -inc 5")
|
||||||
|
end, {description = "increase brightness", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86PowerOff", function ()
|
||||||
|
awful.util.spawn("gksudo shutdown now")
|
||||||
|
end, {description = "Shutdown", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioPlay", function()
|
||||||
|
music.execute_command('play')
|
||||||
|
end, {description = "play or pause the current music", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioStop", function()
|
||||||
|
music.execute_command('stop')
|
||||||
|
end, {description = "stop the current music", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioNext", function()
|
||||||
|
music.execute_command('next')
|
||||||
|
end, {description = "skip to the next music", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86AudioPrev", function()
|
||||||
|
music.execute_command('previous')
|
||||||
|
end, {description = "skip to the previous music", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({ }, "Print", function ()
|
||||||
|
awful.spawn.easy_async_with_shell('gnome-screenshot -fp "`echo -n ' .. home .. '"/Pictures/Captures/Capture du " && date "+%Y-%m-%d %H:%M:%S"`.png"', function() end)
|
||||||
|
end, {description = "capture the screen", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "a", function ()
|
||||||
|
awful.spawn.easy_async(options.browser, function() end)
|
||||||
|
naughty.notify({title = "Starting " .. options.browser})
|
||||||
|
end, {description="start the web browser", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "l", function()
|
||||||
|
awful.spawn.easy_async_with_shell('sleep 1 && xset dpms force off && slock', function() end)
|
||||||
|
end, { description="Locks the screen", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey, "Shift"}, "l", function()
|
||||||
|
awful.spawn.easy_async_with_shell('sleep 1 && xset dpms force off', function() end)
|
||||||
|
end, { description="Locks the screen", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey, "Shift"}, "Tab", function()
|
||||||
|
awful.spawn.easy_async('xdotool key Caps_Lock', function() end)
|
||||||
|
end, {description="switch the caps lock", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#83", function()
|
||||||
|
awful.spawn.easy_async("tvrs enable left", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#84", function()
|
||||||
|
awful.spawn.easy_async("tvrs duplicate", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#85", function()
|
||||||
|
awful.spawn.easy_async("tvrs enable right", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#80", function()
|
||||||
|
awful.spawn.easy_async("tvrs enable above", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#88", function()
|
||||||
|
awful.spawn.easy_async("tvrs enable below", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "#90", function()
|
||||||
|
awful.spawn.easy_async("tvrs disable", function() end)
|
||||||
|
end, {description="lol", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey}, "z", function()
|
||||||
|
awful.spawn.easy_async("firefox https://hangouts.google.com https://messenger.com https://web.telegram.org https://gitter.im https://vortex-n7.slack.com/ https://nextcloud.tforgione.fr/apps/calendar", function() end)
|
||||||
|
naughty.notify({title = "Starting social media"})
|
||||||
|
end, {description="Open social media", group="custom"}),
|
||||||
|
|
||||||
|
awful.key({modkey, "Shift"}, "m", function()
|
||||||
|
awful.spawn.easy_async('sleep 0.5', function()
|
||||||
|
for i = 1, #options.email do
|
||||||
|
os.execute('xdotool type --clearmodifiers ' .. options.email:sub(i,i))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, {description="lol", group="autoinput"})
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
clientkeys = awful.util.table.join(
|
||||||
|
awful.key({ modkey, }, "f",
|
||||||
|
function (c)
|
||||||
|
c.fullscreen = not c.fullscreen
|
||||||
|
c:raise()
|
||||||
|
end,
|
||||||
|
{description = "toggle fullscreen", group = "client"}),
|
||||||
|
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
|
||||||
|
{description = "close", group = "client"}),
|
||||||
|
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
|
||||||
|
{description = "toggle floating", group = "client"}),
|
||||||
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
|
||||||
|
{description = "move to master", group = "client"}),
|
||||||
|
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
|
||||||
|
{description = "move to screen", group = "client"}),
|
||||||
|
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
|
||||||
|
{description = "toggle keep on top", group = "client"}),
|
||||||
|
awful.key({ modkey, }, "n",
|
||||||
|
function (c)
|
||||||
|
-- The client currently has the input focus, so it cannot be
|
||||||
|
-- minimized, since minimized clients can't have the focus.
|
||||||
|
c.minimized = true
|
||||||
|
end ,
|
||||||
|
{description = "minimize", group = "client"}),
|
||||||
|
awful.key({ modkey, }, "m",
|
||||||
|
function (c)
|
||||||
|
c.maximized = not c.maximized
|
||||||
|
c:raise()
|
||||||
|
end ,
|
||||||
|
{description = "maximize", group = "client"})
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Bind all key numbers to tags.
|
||||||
|
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
||||||
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
||||||
|
for i = 1, 10 do
|
||||||
|
globalkeys = awful.util.table.join(globalkeys,
|
||||||
|
-- View tag only.
|
||||||
|
awful.key({ modkey }, "#" .. i + 9,
|
||||||
|
function ()
|
||||||
|
local screen = awful.screen.focused()
|
||||||
|
local tag = screen.tags[i]
|
||||||
|
if tag then
|
||||||
|
tag:view_only()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "view tag #"..i, group = "tag"}),
|
||||||
|
-- Toggle tag display.
|
||||||
|
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
||||||
|
function ()
|
||||||
|
local screen = awful.screen.focused()
|
||||||
|
local tag = screen.tags[i]
|
||||||
|
if tag then
|
||||||
|
awful.tag.viewtoggle(tag)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "toggle tag #" .. i, group = "tag"}),
|
||||||
|
-- Move client to tag.
|
||||||
|
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
||||||
|
function ()
|
||||||
|
if client.focus then
|
||||||
|
local tag = client.focus.screen.tags[i]
|
||||||
|
if tag then
|
||||||
|
client.focus:move_to_tag(tag)
|
||||||
|
tag:view_only()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "move focused client to tag #"..i, group = "tag"}),
|
||||||
|
-- Toggle tag on focused client.
|
||||||
|
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||||
|
function ()
|
||||||
|
if client.focus then
|
||||||
|
local tag = client.focus.screen.tags[i]
|
||||||
|
if tag then
|
||||||
|
client.focus:toggle_tag(tag)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{description = "toggle focused client on tag #" .. i, group = "tag"})
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
clientbuttons = awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
||||||
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
||||||
|
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
||||||
|
|
||||||
|
-- Set keys
|
||||||
|
root.keys(globalkeys)
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Rules
|
||||||
|
-- Rules to apply to new clients (through the "manage" signal).
|
||||||
|
awful.rules.rules = {
|
||||||
|
-- All clients will match this rule.
|
||||||
|
{ rule = { },
|
||||||
|
properties = { border_width = beautiful.border_width,
|
||||||
|
border_color = beautiful.border_normal,
|
||||||
|
focus = awful.client.focus.filter,
|
||||||
|
raise = true,
|
||||||
|
keys = clientkeys,
|
||||||
|
buttons = clientbuttons,
|
||||||
|
screen = awful.screen.preferred,
|
||||||
|
placement = awful.placement.no_overlap+awful.placement.no_offscreen
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Floating clients.
|
||||||
|
{ rule_any = {
|
||||||
|
instance = {
|
||||||
|
"DTA", -- Firefox addon DownThemAll.
|
||||||
|
"copyq", -- Includes session name in class.
|
||||||
|
},
|
||||||
|
class = {
|
||||||
|
"Arandr",
|
||||||
|
"Gpick",
|
||||||
|
"Kruler",
|
||||||
|
"MessageWin", -- kalarm.
|
||||||
|
"Sxiv",
|
||||||
|
"Wpa_gui",
|
||||||
|
"pinentry",
|
||||||
|
"veromix",
|
||||||
|
"xtightvncviewer"},
|
||||||
|
|
||||||
|
name = {
|
||||||
|
"Event Tester", -- xev.
|
||||||
|
},
|
||||||
|
role = {
|
||||||
|
"AlarmWindow", -- Thunderbird's calendar.
|
||||||
|
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
|
||||||
|
}
|
||||||
|
}, properties = { floating = true }},
|
||||||
|
|
||||||
|
-- Add titlebars to normal clients and dialogs
|
||||||
|
{ rule_any = {type = { "normal", "dialog" }
|
||||||
|
}, properties = { titlebars_enabled = false }
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Set Firefox to always map on the tag named "2" on screen 1.
|
||||||
|
-- { rule = { class = "Firefox" },
|
||||||
|
-- properties = { screen = 1, tag = "2" } },
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Signals
|
||||||
|
-- Signal function to execute when a new client appears.
|
||||||
|
client.connect_signal("manage", function (c)
|
||||||
|
-- Set the windows at the slave,
|
||||||
|
-- i.e. put it at the end of others instead of setting it master.
|
||||||
|
-- if not awesome.startup then awful.client.setslave(c) end
|
||||||
|
|
||||||
|
if awesome.startup and
|
||||||
|
not c.size_hints.user_position
|
||||||
|
and not c.size_hints.program_position then
|
||||||
|
-- Prevent clients from being unreachable after screen count changes.
|
||||||
|
awful.placement.no_offscreen(c)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Add a titlebar if titlebars_enabled is set to true in the rules.
|
||||||
|
client.connect_signal("request::titlebars", function(c)
|
||||||
|
-- buttons for the titlebar
|
||||||
|
local buttons = awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function()
|
||||||
|
client.focus = c
|
||||||
|
c:raise()
|
||||||
|
awful.mouse.client.move(c)
|
||||||
|
end),
|
||||||
|
awful.button({ }, 3, function()
|
||||||
|
client.focus = c
|
||||||
|
c:raise()
|
||||||
|
awful.mouse.client.resize(c)
|
||||||
|
end)
|
||||||
|
)
|
||||||
|
|
||||||
|
awful.titlebar(c) : setup {
|
||||||
|
{ -- Left
|
||||||
|
awful.titlebar.widget.iconwidget(c),
|
||||||
|
buttons = buttons,
|
||||||
|
layout = wibox.layout.fixed.horizontal
|
||||||
|
},
|
||||||
|
{ -- Middle
|
||||||
|
{ -- Title
|
||||||
|
align = "center",
|
||||||
|
widget = awful.titlebar.widget.titlewidget(c)
|
||||||
|
},
|
||||||
|
buttons = buttons,
|
||||||
|
layout = wibox.layout.flex.horizontal
|
||||||
|
},
|
||||||
|
{ -- Right
|
||||||
|
awful.titlebar.widget.floatingbutton (c),
|
||||||
|
awful.titlebar.widget.maximizedbutton(c),
|
||||||
|
awful.titlebar.widget.stickybutton (c),
|
||||||
|
awful.titlebar.widget.ontopbutton (c),
|
||||||
|
awful.titlebar.widget.closebutton (c),
|
||||||
|
layout = wibox.layout.fixed.horizontal()
|
||||||
|
},
|
||||||
|
layout = wibox.layout.align.horizontal
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Enable sloppy focus, so that focus follows mouse.
|
||||||
|
client.connect_signal("mouse::enter", function(c)
|
||||||
|
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
||||||
|
and awful.client.focus.filter(c) then
|
||||||
|
client.focus = c
|
||||||
|
end
|
||||||
|
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)
|
||||||
|
|
||||||
|
-- }}}
|
|
@ -0,0 +1,30 @@
|
||||||
|
local module = {}
|
||||||
|
|
||||||
|
module.starts_with = function(String,Start)
|
||||||
|
return string.sub(String,1,string.len(Start))==Start
|
||||||
|
end
|
||||||
|
|
||||||
|
module.split = function(str, delimiter)
|
||||||
|
if str == nil then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
local ret = {''}
|
||||||
|
count = 1
|
||||||
|
for i = 1, string.len(str) do
|
||||||
|
local c = str:sub(i,i)
|
||||||
|
if c == delimiter then
|
||||||
|
count = count + 1
|
||||||
|
ret[count] = ''
|
||||||
|
else
|
||||||
|
ret[count] = ret[count] .. c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
module.pad = function(str, len, char)
|
||||||
|
if char == nil then char = ' ' end
|
||||||
|
return str .. string.rep(char, len - #str)
|
||||||
|
end
|
||||||
|
|
||||||
|
return module
|
|
@ -0,0 +1,102 @@
|
||||||
|
---------------------------
|
||||||
|
-- Default awesome theme --
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
local theme = {}
|
||||||
|
|
||||||
|
theme.font = "sans 8"
|
||||||
|
|
||||||
|
theme.bg_normal = "#22222200"
|
||||||
|
theme.bg_focus = "#535d6c00"
|
||||||
|
theme.bg_urgent = "#ff000000"
|
||||||
|
theme.bg_minimize = "#44444400"
|
||||||
|
theme.bg_systray = theme.bg_normal
|
||||||
|
|
||||||
|
theme.fg_normal = "#cccccc"
|
||||||
|
theme.fg_focus = "#ffffff"
|
||||||
|
theme.fg_urgent = "#ffffff"
|
||||||
|
theme.fg_minimize = "#ffffff"
|
||||||
|
|
||||||
|
theme.useless_gap = 0
|
||||||
|
theme.border_width = 1
|
||||||
|
theme.border_normal = "#39404b"
|
||||||
|
theme.border_focus = "#6d7a8d"
|
||||||
|
theme.border_marked = "#91231c"
|
||||||
|
|
||||||
|
-- There are other variable sets
|
||||||
|
-- overriding the default one when
|
||||||
|
-- defined, the sets are:
|
||||||
|
-- taglist_[bg|fg]_[focus|urgent|occupied|empty]
|
||||||
|
-- tasklist_[bg|fg]_[focus|urgent]
|
||||||
|
-- titlebar_[bg|fg]_[normal|focus]
|
||||||
|
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
|
||||||
|
-- mouse_finder_[color|timeout|animate_timeout|radius|factor]
|
||||||
|
-- Example:
|
||||||
|
--theme.taglist_bg_focus = "#ff0000"
|
||||||
|
|
||||||
|
theme.tooltip_font = "Inconsolata 12"
|
||||||
|
|
||||||
|
-- Display the taglist squares
|
||||||
|
theme.taglist_squares_sel = "/usr/share/awesome/themes/default/taglist/squarefw.png"
|
||||||
|
theme.taglist_squares_unsel = "/usr/share/awesome/themes/default/taglist/squarew.png"
|
||||||
|
|
||||||
|
-- Variables set for theming the menu:
|
||||||
|
-- menu_[bg|fg]_[normal|focus]
|
||||||
|
-- menu_[border_color|border_width]
|
||||||
|
theme.menu_submenu_icon = "/usr/share/awesome/themes/default/submenu.png"
|
||||||
|
theme.menu_height = 15
|
||||||
|
theme.menu_width = 100
|
||||||
|
|
||||||
|
-- You can add as many variables as
|
||||||
|
-- you wish and access them by using
|
||||||
|
-- beautiful.variable in your rc.lua
|
||||||
|
--theme.bg_widget = "#cc0000"
|
||||||
|
|
||||||
|
-- Define the image to load
|
||||||
|
theme.titlebar_close_button_normal = "/usr/share/awesome/themes/default/titlebar/close_normal.png"
|
||||||
|
theme.titlebar_close_button_focus = "/usr/share/awesome/themes/default/titlebar/close_focus.png"
|
||||||
|
|
||||||
|
theme.titlebar_ontop_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/ontop_normal_inactive.png"
|
||||||
|
theme.titlebar_ontop_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/ontop_focus_inactive.png"
|
||||||
|
theme.titlebar_ontop_button_normal_active = "/usr/share/awesome/themes/default/titlebar/ontop_normal_active.png"
|
||||||
|
theme.titlebar_ontop_button_focus_active = "/usr/share/awesome/themes/default/titlebar/ontop_focus_active.png"
|
||||||
|
|
||||||
|
theme.titlebar_sticky_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/sticky_normal_inactive.png"
|
||||||
|
theme.titlebar_sticky_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/sticky_focus_inactive.png"
|
||||||
|
theme.titlebar_sticky_button_normal_active = "/usr/share/awesome/themes/default/titlebar/sticky_normal_active.png"
|
||||||
|
theme.titlebar_sticky_button_focus_active = "/usr/share/awesome/themes/default/titlebar/sticky_focus_active.png"
|
||||||
|
|
||||||
|
theme.titlebar_floating_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/floating_normal_inactive.png"
|
||||||
|
theme.titlebar_floating_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/floating_focus_inactive.png"
|
||||||
|
theme.titlebar_floating_button_normal_active = "/usr/share/awesome/themes/default/titlebar/floating_normal_active.png"
|
||||||
|
theme.titlebar_floating_button_focus_active = "/usr/share/awesome/themes/default/titlebar/floating_focus_active.png"
|
||||||
|
|
||||||
|
theme.titlebar_maximized_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/maximized_normal_inactive.png"
|
||||||
|
theme.titlebar_maximized_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/maximized_focus_inactive.png"
|
||||||
|
theme.titlebar_maximized_button_normal_active = "/usr/share/awesome/themes/default/titlebar/maximized_normal_active.png"
|
||||||
|
theme.titlebar_maximized_button_focus_active = "/usr/share/awesome/themes/default/titlebar/maximized_focus_active.png"
|
||||||
|
|
||||||
|
theme.wallpaper = "/home/thomas/Pictures/Wallpapers/terminal.jpg"
|
||||||
|
|
||||||
|
-- You can use your own layout icons like this:
|
||||||
|
theme.layout_fairh = "/usr/share/awesome/themes/default/layouts/fairhw.png"
|
||||||
|
theme.layout_fairv = "/usr/share/awesome/themes/default/layouts/fairvw.png"
|
||||||
|
theme.layout_floating = "/usr/share/awesome/themes/default/layouts/floatingw.png"
|
||||||
|
theme.layout_magnifier = "/usr/share/awesome/themes/default/layouts/magnifierw.png"
|
||||||
|
theme.layout_max = "/usr/share/awesome/themes/default/layouts/maxw.png"
|
||||||
|
theme.layout_fullscreen = "/usr/share/awesome/themes/default/layouts/fullscreenw.png"
|
||||||
|
theme.layout_tilebottom = "/usr/share/awesome/themes/default/layouts/tilebottomw.png"
|
||||||
|
theme.layout_tileleft = "/usr/share/awesome/themes/default/layouts/tileleftw.png"
|
||||||
|
theme.layout_tile = "/usr/share/awesome/themes/default/layouts/tilew.png"
|
||||||
|
theme.layout_tiletop = "/usr/share/awesome/themes/default/layouts/tiletopw.png"
|
||||||
|
theme.layout_spiral = "/usr/share/awesome/themes/default/layouts/spiralw.png"
|
||||||
|
theme.layout_dwindle = "/usr/share/awesome/themes/default/layouts/dwindlew.png"
|
||||||
|
|
||||||
|
theme.awesome_icon = "/usr/share/awesome/icons/awesome16.png"
|
||||||
|
|
||||||
|
-- Define the icon theme for application icons. If not set then the icons
|
||||||
|
-- from /usr/share/icons and /usr/share/icons/hicolor will be used.
|
||||||
|
theme.icon_theme = nil
|
||||||
|
|
||||||
|
return theme
|
||||||
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -0,0 +1,29 @@
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local awful = require("awful")
|
||||||
|
|
||||||
|
volume_widget = wibox.widget.textbox()
|
||||||
|
volume_widget:set_align("right")
|
||||||
|
|
||||||
|
function update_volume()
|
||||||
|
|
||||||
|
awful.spawn.easy_async('amixer sget Master', function(stdout, stderr)
|
||||||
|
local status = stdout
|
||||||
|
local widget = volume_widget
|
||||||
|
|
||||||
|
-- local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100
|
||||||
|
local volume = string.match(status, "(%d?%d?%d)%%")
|
||||||
|
volume = string.format("% 3d", volume)
|
||||||
|
status = string.match(status, "%[(o[^%]]*)%]")
|
||||||
|
|
||||||
|
if string.find(status, "on", 1, true) then
|
||||||
|
-- For the volume numbers
|
||||||
|
volume = volume .. "%"
|
||||||
|
else
|
||||||
|
-- For the mute button
|
||||||
|
volume = volume .. "M"
|
||||||
|
end
|
||||||
|
widget:set_markup("V :" .. volume)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
update_volume()
|