Compare commits

...

20 Commits

Author SHA1 Message Date
23301aec85 default config: update lock command for i3lock-color update 2021-05-31 10:50:27 +02:00
7c6162d51a Make sure fullscreen clients get a correct fullscreen geometry
Co-authored-by: Mițca Dumitru <dumitru0mitca@gmail.com>
2021-05-15 20:04:34 +02:00
a0024216e8 Disable titlebars 2021-04-08 12:44:51 +02:00
6db061641d Make clock more readable 2021-04-08 12:44:29 +02:00
034462f8f8 keyboard_layout.lua: quote command argument 2021-04-08 12:43:56 +02:00
0bda31d908 media_control.lua: make volume management fully async 2021-04-08 12:42:13 +02:00
e8a91d98ce Don't ignore wallpaper aspect ratio 2021-02-21 19:30:44 +01:00
55ff9a842d Add hotkey to manually toggle titlebar
Co-authored-by: Arkhist <peyrille.benjamin@gmail.com>
2021-02-17 11:38:02 +01:00
dcaf31a930 Fix hotkey collision 2021-02-17 11:37:32 +01:00
66c0c041c1 Update author name and README.md todo list
Co-authored-by: Arkhist <peyrille.benjamin@gmail.com>
2021-02-17 11:29:06 +01:00
4d0173f7e6 Hide titlebar for clients that request so
Co-authored-by: Arkhist <peyrille.benjamin@gmail.com>
2021-02-17 11:26:16 +01:00
2ff77572ff Revert "Disable titlebars on dialogs"
This reverts commit e689f17a56.
2021-02-17 11:23:51 +01:00
6e975df154 Merge remote-tracking branch 'origin/arisu-edits' into arisu-edits 2021-02-17 11:22:48 +01:00
4b7ab5f5ff Force set default keyboard layout 2021-02-17 11:14:39 +01:00
0873d1719d Power menu: add sleep, hybrid sleep and hibernate buttons 2020-12-31 13:29:58 +01:00
cd1f142003 Add theme.lua contents 2020-12-27 08:29:41 +01:00
1d1cd0550a Add config.lua contents 2020-12-27 08:28:43 +01:00
b5ca1e485c Add trailing new line to config.lua and theme.lua 2020-12-27 08:24:44 +01:00
a6b0a8b02a Remove tags UI 2020-12-27 08:21:18 +01:00
b5f391f3b8 Customize clock format 2020-12-27 08:21:02 +01:00
11 changed files with 369 additions and 249 deletions

View File

@ -28,10 +28,11 @@ By default, Simple Awesome uses
- Replace the os menu with a custom widget - Replace the os menu with a custom widget
- Add backlight media keys to xbacklight command functionnality - Add backlight media keys to xbacklight command functionnality
- Add icon to the battery widget - 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 - Add aliases to rofi https://github.com/davatorium/rofi/issues/97

View 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
View 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

View File

@ -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

View File

@ -25,7 +25,7 @@ config.awesome = {
application_launcher_cmd = "rofi -show run -config " .. awful.util.getdir("config") .. "/assets/rofi/themes/paper-float.rasi", application_launcher_cmd = "rofi -show run -config " .. awful.util.getdir("config") .. "/assets/rofi/themes/paper-float.rasi",
-- Screen locker -- 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", -- lock_command = "xscreensaver-command -lock",
-- Terminal -- Terminal

View File

@ -187,6 +187,7 @@ theme.volume_osd_border_color = theme.border_normal
theme.volume_osd_border_width = dpi(0) theme.volume_osd_border_width = dpi(0)
theme.volume_osd_progress_bg = theme.bg_minimize theme.volume_osd_progress_bg = theme.bg_minimize
theme.volume_osd_progress_color = "#ffffff" 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_color = theme.volume_osd_border_color
theme.volume_osd_progress_border_width = dpi(0) theme.volume_osd_progress_border_width = dpi(0)
theme.volume_osd_image_color = "#ffffff" theme.volume_osd_image_color = "#ffffff"

2
rc.lua
View File

@ -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. -- To configure Simple Awesome without losing your changes when updating, see the `config.lua` file.
-- --
require("simple") require("simple")

View File

@ -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
@ -168,10 +171,12 @@ local launcher = awful.widget.button({
launcher:buttons(gears.table.join(launcher:buttons(), launcher:buttons(gears.table.join(launcher:buttons(),
awful.button({}, 1, nil, function() showAppLauncher(false) end))) 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) 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({ os_menu = awful.widget.launcher({
image = beautiful.awesome_icon, image = beautiful.awesome_icon,
@ -183,6 +188,9 @@ os_menu = awful.widget.launcher({
{ "Open terminal", config.awesome.terminal }, { "Open terminal", config.awesome.terminal },
{ "Lock", lockScreen, lock_icon }, { "Lock", lockScreen, lock_icon },
{ "Logout", function() awesome.quit() end, logout_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 }, { "Restart", function() os.execute('shutdown -r now') end, restart_icon },
{ "Shutdown", function() os.execute('shutdown now') end, shutdown_icon }, { "Shutdown", function() os.execute('shutdown now') end, shutdown_icon },
} }
@ -192,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
@ -237,7 +246,7 @@ local function set_wallpaper(s)
if type(wallpaper) == "function" then if type(wallpaper) == "function" then
wallpaper = wallpaper(s) wallpaper = wallpaper(s)
end end
gears.wallpaper.maximized(wallpaper, s, true) gears.wallpaper.maximized(wallpaper, s)
end end
end end
@ -261,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 {
@ -325,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
@ -336,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,
}, },
@ -495,7 +505,7 @@ clientkeys = gears.table.join(-- tiling
{ description = "toggle fullscreen", group = "client" }), { description = "toggle fullscreen", group = "client" }),
awful.key({ config.keys.modkey, "Shift" }, "c", function(c) c:kill() end, awful.key({ config.keys.modkey, "Shift" }, "c", function(c) c:kill() end,
{ description = "close", group = "client" }), { 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" }), { description = "toggle floating", group = "client" }),
awful.key({ config.keys.modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end, awful.key({ config.keys.modkey, "Control" }, "Return", function(c) c:swap(awful.client.getmaster()) end,
{ description = "move to master", group = "client" }), { description = "move to master", group = "client" }),
@ -527,55 +537,64 @@ clientkeys = gears.table.join(-- tiling
c.maximized_horizontal = not c.maximized_horizontal c.maximized_horizontal = not c.maximized_horizontal
c:raise() c:raise()
end, 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. -- 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 })
@ -653,9 +672,9 @@ awful.rules.rules = {
-- Add titlebars to normal clients and dialogs -- Add titlebars to normal clients and dialogs
{ {
rule_any = { rule_any = {
type = { "normal" } 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.
@ -710,6 +729,10 @@ client.connect_signal("request::titlebars", function(c)
}, },
layout = wibox.layout.align.horizontal layout = wibox.layout.align.horizontal
} }
if c.requests_no_titlebar then
awful.titlebar.hide(c)
end
end) end)
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
@ -722,3 +745,17 @@ end
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus 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) 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)

View File

@ -23,109 +23,116 @@ local config = require("config")
local hasPlayerctl = os.execute("playerctl -v") == true local hasPlayerctl = os.execute("playerctl -v") == true
-- playerctl -- playerctl
function sendToPlayerctl(command) function sendToPlayerctl(command, callback)
os.execute("playerctl " .. command) callback = callback or function()
end
awful.spawn.easy_async("playerctl " .. command, callback)
end end
-- Spotify -- Spotify
function sendToSpotify(command) function sendToSpotify(command, callback)
awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command) 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 end
-- Brightness control -- Brightness control
function getBrightness() function getBrightness(callback)
local handle = io.popen("xbacklight -get") callback = callback or function()
local brightness = handle:read("*a") end
handle:close()
return brightness awful.spawn.easy_async("xbacklight -get", function(stdout, stderr, reason, exit_code)
callback(stdout)
end)
end end
function increaseBrightness() function increaseBrightness(callback)
os.execute("xbacklight -inc 2") callback = callback or function()
end
awful.spawn.easy_async("xbacklight -inc 2", callback)
end end
function decreaseBrightness() function decreaseBrightness(callback)
os.execute("xbacklight -dec 2") callback = callback or function()
end
awful.spawn.easy_async("xbacklight -dec 2", callback)
end end
-- Volume control -- Volume control
function getVolume() function isMuted(callback)
if isMuted() then return 0 end 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)
local handle = io.popen("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' -M | awk -F\"[][]\" '/%/ { print $2 }' | head -n 1", "r") callback(string.match(string.gsub(stdout, "[\n]+", ""), "off"))
local volume = string.gsub(handle:read("*a"), "[\n%%]+", "") / 100 end)
handle:close()
return volume
end end
function isMuted() function getVolume(callback)
local handle = io.popen("amixer " .. config.audio.card .. " sget '" .. config.audio.device .. "' | egrep 'Playback.*?\\[o' | egrep -o '\\[o.+\\]'", "r") 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)
local muted = string.match(string.gsub(handle:read("*a"), "[\n]+", ""), "off") callback(string.gsub(stdout, "[\n%%]+", "") / 100)
handle:close() end)
return muted
end end
function getVolumeImage(volume) function getVolumeImage(volume)
local path = beautiful.volume_osd_icon_3 local path = beautiful.volume_osd_icon_3
if volume < 0.667 then if volume < 0.667 then
path = beautiful.volume_osd_icon_2 path = beautiful.volume_osd_icon_2
end end
if volume < 0.334 then if volume < 0.334 then
path = beautiful.volume_osd_icon_1 path = beautiful.volume_osd_icon_1
end end
if volume <= 0 then if volume <= 0 then
path = beautiful.volume_osd_icon_0 path = beautiful.volume_osd_icon_0
end end
return gears.color.recolor_image(path, beautiful.volume_osd_image_color) return gears.color.recolor_image(path, beautiful.volume_osd_image_color)
end end
local volumeWibox = wibox({ local volumeWibox = wibox({
ontop = true, ontop = true,
bg = beautiful.volume_osd_bg, bg = beautiful.volume_osd_bg,
border_width = beautiful.volume_osd_border_width, border_width = beautiful.volume_osd_border_width,
border_color = beautiful.volume_osd_border_color, border_color = beautiful.volume_osd_border_color,
shape = beautiful.volume_osd_shape, shape = beautiful.volume_osd_shape,
width = beautiful.volume_osd_width, width = beautiful.volume_osd_width,
height = beautiful.volume_osd_bar_height + beautiful.volume_osd_padding * 3, height = beautiful.volume_osd_bar_height + beautiful.volume_osd_padding * 3,
widget = wibox.widget { widget = wibox.widget {
{ {
{ {
image = getVolumeImage(1), image = getVolumeImage(1),
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
}, },
left = beautiful.volume_osd_padding, left = beautiful.volume_osd_padding,
right = beautiful.volume_osd_padding, right = beautiful.volume_osd_padding,
top = beautiful.volume_osd_padding, top = beautiful.volume_osd_padding,
bottom = 0, bottom = 0,
widget = wibox.container.margin, widget = wibox.container.margin,
}, },
{ {
{ {
{ {
max_value = 1, max_value = 1,
value = 0.33, value = 0.33,
shape = gears.shape.rounded_bar, shape = gears.shape.rounded_bar,
bar_shape = gears.shape.rounded_bar, bar_shape = gears.shape.rounded_bar,
margins = beautiful.volume_osd_padding + 4, margins = beautiful.volume_osd_padding + 4,
color = beautiful.volume_osd_progress_color, color = beautiful.volume_osd_progress_color,
background_color = beautiful.volume_osd_progress_bg, background_color = beautiful.volume_osd_progress_bg,
border_color = beautiful.volume_osd_progress_border_color, border_color = beautiful.volume_osd_progress_border_color,
border_width = beautiful.volume_osd_progress_border_width, border_width = beautiful.volume_osd_progress_border_width,
widget = wibox.widget.progressbar widget = wibox.widget.progressbar
}, },
forced_width = 80, forced_width = 80,
forced_height = 80, forced_height = 80,
direction = "east", direction = "east",
layout = wibox.container.rotate, layout = wibox.container.rotate,
}, },
left = beautiful.volume_osd_padding, left = beautiful.volume_osd_padding,
right = beautiful.volume_osd_padding, right = beautiful.volume_osd_padding,
top = 0, top = 0,
bottom = beautiful.volume_osd_padding, bottom = beautiful.volume_osd_padding,
widget = wibox.container.margin, widget = wibox.container.margin,
}, },
layout = wibox.layout.align.vertical layout = wibox.layout.align.vertical
}, },
}) })
local imagebox = volumeWibox.widget:get_children()[1]:get_children()[1] local imagebox = volumeWibox.widget:get_children()[1]:get_children()[1]
@ -135,116 +142,127 @@ local timer = nil
-- {{{ Control -- {{{ Control
local playPause = function() local playPause = function()
if hasPlayerctl then if hasPlayerctl then
sendToPlayerctl("play-pause") sendToPlayerctl("play-pause")
else else
sendToSpotify("PlayPause") sendToSpotify("PlayPause")
end end
end end
local nextTrack = function() local nextTrack = function()
if hasPlayerctl then if hasPlayerctl then
sendToPlayerctl("next") sendToPlayerctl("next")
else else
sendToSpotify("Next") sendToSpotify("Next")
end end
end end
local previousTrack = function() local previousTrack = function()
if hasPlayerctl then if hasPlayerctl then
sendToPlayerctl("previous") sendToPlayerctl("previous")
else else
sendToSpotify("Previous") sendToSpotify("Previous")
end end
end end
local displayVolume = function() local displayVolume = function()
-- Update screen isMuted(function(muted)
local screen = awful.screen:focused() getVolume(function(volume)
volumeWibox.screen = screen -- 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
-- Position if timer ~= nil and timer.started then
local position = beautiful.volume_osd_position(screen.geometry.width, screen.geometry.height, beautiful.volume_osd_width, beautiful.volume_osd_height) timer:again()
volumeWibox:geometry({ return
x = (screen.geometry.x + position[1]), end
y = (screen.geometry.y + position[2])
})
-- Get volume -- Update screen
local volume = getVolume() local screen = awful.screen:focused()
volumeWibox.screen = screen
-- Update values -- Position
imagebox.image = getVolumeImage(volume) local position = beautiful.volume_osd_position(screen.geometry.width, screen.geometry.height, beautiful.volume_osd_width, beautiful.volume_osd_height)
progressbar.value = volume volumeWibox:geometry({
x = (screen.geometry.x + position[1]),
y = (screen.geometry.y + position[2])
})
-- Show -- Show
volumeWibox.visible = true volumeWibox.visible = true
-- Schedule hide -- Schedule hide
if timer ~= nil then if timer ~= nil then
timer:stop() timer:stop()
end end
timer = gears.timer { timer = gears.timer {
timeout = config.volume_osd_timeout, timeout = config.volume_osd_timeout,
callback = function() callback = function()
volumeWibox.visible = false volumeWibox.visible = false
timer:stop() timer:stop()
timer = nil timer = nil
end end
} }
timer:start() timer:start()
end)
end)
end end
local raiseVolume = function() 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() displayVolume()
end)
end end
local lowerVolume = function() 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() displayVolume()
end)
end end
local toggleMute = function() local toggleMute = function()
local muted = isMuted() isMuted(function(muted)
os.execute("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' " .. (muted and 'on' or 'off')) awful.spawn.easy_async("amixer " .. config.audio.card .. " set '" .. config.audio.device .. "' " .. (muted and 'on' or 'off'), function(stdout, stderr, reason, exit_code)
displayVolume() displayVolume()
end)
end)
end end
-- }}} -- }}}
function getKeys(keys) function getKeys(keys)
if config.audio.card == 'disabled' then if config.audio.card == 'disabled' then
return return
-- Media control -- Media control
hotkey.make(keys.playPause, playPause, hotkey.make(keys.playPause, playPause,
{ description = "Toggle Play / Pause", group = "media control" }), { description = "Toggle Play / Pause", group = "media control" }),
hotkey.make(keys.nextTrack, nextTrack, hotkey.make(keys.nextTrack, nextTrack,
{ description = "Next track", group = "media control" }), { description = "Next track", group = "media control" }),
hotkey.make(keys.previousTrack, previousTrack, hotkey.make(keys.previousTrack, previousTrack,
{ description = "Previous track", group = "media control" }) { description = "Previous track", group = "media control" })
end end
return return
-- Volume control -- Volume control
hotkey.make(keys.raiseVolume, raiseVolume, hotkey.make(keys.raiseVolume, raiseVolume,
{ description = "Raise volume", group = "media control" }), { description = "Raise volume", group = "media control" }),
hotkey.make(keys.lowerVolume, lowerVolume, hotkey.make(keys.lowerVolume, lowerVolume,
{ description = "Lower volume", group = "media control" }), { description = "Lower volume", group = "media control" }),
hotkey.make(keys.toggleMute, toggleMute, hotkey.make(keys.toggleMute, toggleMute,
{ description = "Toggle mute audio", group = "media control" }), { description = "Toggle mute audio", group = "media control" }),
-- Media control -- Media control
hotkey.make(keys.playPause, playPause, hotkey.make(keys.playPause, playPause,
{ description = "Toggle Play / Pause", group = "media control" }), { description = "Toggle Play / Pause", group = "media control" }),
hotkey.make(keys.nextTrack, nextTrack, hotkey.make(keys.nextTrack, nextTrack,
{ description = "Next track", group = "media control" }), { description = "Next track", group = "media control" }),
hotkey.make(keys.previousTrack, previousTrack, hotkey.make(keys.previousTrack, previousTrack,
{ description = "Previous track", group = "media control" }), { description = "Previous track", group = "media control" }),
-- Backlight control -- Backlight control
hotkey.make(keys.brightnessUp, increaseBrightness, hotkey.make(keys.brightnessUp, increaseBrightness,
{ description = "Increase screen backlight brightness", group = "media control"}), { description = "Increase screen backlight brightness", group = "media control" }),
hotkey.make(keys.brightnessDown, decreaseBrightness, hotkey.make(keys.brightnessDown, decreaseBrightness,
{ description = "Decrease screen backlight brightness", group = "media control"}) { description = "Decrease screen backlight brightness", group = "media control" })
end end
return { return {
getKeys = getKeys, getKeys = getKeys,
} }

View File

@ -11,7 +11,7 @@ local layouts = config.widgets.keyboard_layout.layouts
local current_layout_index = 1 local current_layout_index = 1
function switchLayout() function switchLayout()
current_layout_index = (current_layout_index % #(layouts)) + 1 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 end
return { return {

View File

@ -1,3 +1,6 @@
local theme = require("default_theme") local theme = require("default_theme")
theme.useless_gap = 4
theme.border_width = 0
return theme return theme