Skip to content

Instantly share code, notes, and snippets.

@jeffmhubbard
Created August 13, 2021 21:08
Show Gist options
  • Save jeffmhubbard/ec67ade696c7b2638d90c98d43bc0e0f to your computer and use it in GitHub Desktop.
Save jeffmhubbard/ec67ade696c7b2638d90c98d43bc0e0f to your computer and use it in GitHub Desktop.
Minimal rc.lua with randow wallpaper and key binding
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
local beautiful = require("beautiful")
local menubar = require("menubar")
beautiful.init(gears.filesystem.get_themes_dir() .. "gtk/theme.lua")
local terminal = "xterm"
local modkey = "Mod4"
menubar.utils.terminal = terminal
awful.layout.layouts = {
awful.layout.suit.floating,
}
awful.screen.connect_for_each_screen(function(s)
awful.tag({ "uno" }, s, awful.layout.layouts[1])
end)
local walldir = "/usr/share/backgrounds/archlinux"
local interval = 600
local wallpaper_timer = gears.timer {
timeout = interval,
autostart = true
}
wallpaper_timer:connect_signal("timeout", function()
local files = {}
local cmd = 'find ' .. walldir .. ' -type f'
awful.spawn.with_line_callback (cmd, {
stdout = function(line)
table.insert(files, line)
end,
output_done = function()
local index = math.random(1, #files)
local image = files[index]
for s = 1, screen.count() do
gears.wallpaper.maximized(image, s, true)
end
end,
})
end)
if wallpaper_timer.started then
wallpaper_timer:emit_signal('timeout')
end
local globalkeys = gears.table.join(
awful.key({ modkey, }, "Return", function () awful.spawn(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, }, "w", function() wallpaper_timer:emit_signal('timeout') end,
{description = "quit awesome", group = "awesome"}),
awful.key({ modkey }, "p", function() menubar.show() end,
{description = "show the menubar", group = "launcher"})
)
local clientbuttons = gears.table.join(
awful.button({ }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
end),
awful.button({ modkey }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({ modkey }, 3, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.resize(c)
end)
)
root.keys(globalkeys)
awful.rules.rules = {
{
rule = { },
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
}
}
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment