Adding fennel to awesome config with basic rules

This commit is contained in:
Chris Cochrun 2020-09-06 13:54:31 -05:00
parent 42882489bf
commit ebf15f2270
9 changed files with 609 additions and 304 deletions

View file

@ -1,2 +1,2 @@
#+TITLE: Readme
#+PROPERTY: header-args :tangle rc.lua
#+DESCRIPTION: My Awesome config

9
awesome/init.fnl Normal file
View file

@ -0,0 +1,9 @@
(local awful (require "awful"))
(local ruled (require "ruled"))
(local rules (require "rules"))
(local beautiful (require "beautiful"))
(local gears (require "gears"))
;; (gears.wallpaper.set (beautiful.wallpaper))
(set awful.rules.rules rules)

256
awesome/keys.lua Normal file
View file

@ -0,0 +1,256 @@
local awful = require('awful')
local gears = require('gears')
require('awful.autofocus')
local modkey = "Mod4"
local altkey = "Mod1"
local dpi = require('beautiful').xresources.apply_dpi
local clientKeys =
awful.util.table.join(
-- toggle fullscreen
awful.key(
{modkey},
'f',
function(c)
-- Toggle fullscreen
c.fullscreen = not c.fullscreen
c:raise()
end,
{description = 'toggle fullscreen', group = 'client'}
),
-- close client
awful.key(
{modkey},
'c',
function(c)
c:kill()
end,
{description = 'close', group = 'client'}
),
-- Default client focus
awful.key(
{modkey},
'd',
function()
awful.client.focus.byidx(1)
end,
{description = 'focus next by index', group = 'client'}
),
awful.key(
{modkey},
'a',
function()
awful.client.focus.byidx(-1)
end,
{description = 'focus previous by index', group = 'client'}
),
awful.key(
{ modkey, "Shift" },
"d",
function ()
awful.client.swap.byidx(1)
end,
{description = "swap with next client by index", group = "client"}
),
awful.key(
{ modkey, "Shift" },
"a",
function ()
awful.client.swap.byidx(-1)
end,
{description = "swap with next client by index", group = "client"}
),
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()
if client.focus then
client.focus:raise()
end
end,
{description = 'go back', group = 'client'}
),
awful.key(
{modkey},
'n',
function(c)
c.minimized = true
end,
{description = "minimize client", group = 'client'}
),
-- move floating client to center
awful.key(
{ modkey, "Shift" },
"c",
function(c)
local focused = awful.screen.focused()
awful.placement.centered(c, {
honor_workarea = true
})
end,
{description = 'align a client to the center of the focused screen.', group = "client"}
),
-- toggle client floating mode
awful.key(
{modkey},
'c',
function(c)
c.fullscreen = false
c.maximized = false
c.floating = not c.floating
c:raise()
end,
{description = 'toggle floating', group = 'client'}
),
-- move client position
awful.key(
{modkey},
'Up',
function(c)
if c.floating then
c:relative_move(0, dpi(-10), 0, 0)
end
end,
{description = 'move floating client up by 10 px', group = 'client'}
),
awful.key(
{modkey},
'Down',
function(c)
if c.floating then
c:relative_move(0, dpi(10), 0, 0)
end
end,
{description = 'move floating client down by 10 px', group = 'client'}
),
awful.key(
{modkey},
'Left',
function(c)
if c.floating then
c:relative_move(dpi(-10), 0, 0, 0)
end
end,
{description = 'move floating client to the left by 10 px', group = 'client'}
),
awful.key(
{modkey},
'Right',
function(c)
if c.floating then
c:relative_move(dpi(10), 0, 0, 0)
end
end,
{description = 'move floating client to the right by 10 px', group = 'client'}
),
-- Increasing floating client size
awful.key(
{modkey, 'Shift'},
'Up',
function(c)
if c.floating then
c:relative_move(0, dpi(-10), 0, dpi(10))
end
end,
{description = 'increase floating client size vertically by 10 px up', group = 'client'}
),
awful.key(
{modkey, 'Shift'},
'Down',
function(c)
if c.floating then
c:relative_move(0, 0, 0, dpi(10))
end
end,
{description = 'increase floating client size vertically by 10 px down', group = 'client'}
),
awful.key(
{modkey, 'Shift'},
'Left',
function(c)
if c.floating then
c:relative_move(dpi(-10), 0, dpi(10), 0)
end
end,
{description = 'increase floating client size horizontally by 10 px left', group = 'client'}
),
awful.key(
{modkey, 'Shift'},
'Right',
function(c)
if c.floating then
c:relative_move(0, 0, dpi(10), 0)
end
end,
{description = 'increase floating client size horizontally by 10 px right', group = 'client'}
),
-- Decreasing floating client size
awful.key(
{modkey, 'Control'},
'Up',
function(c)
if c.floating and c.height > 10 then
c:relative_move(0, 0, 0, dpi(-10))
end
end,
{description = 'decrease floating client size vertically by 10 px up', group = 'client'}
),
awful.key(
{modkey, 'Control'},
'Down',
function(c)
if c.floating then
local c_height = c.height
c:relative_move(0, 0, 0, dpi(-10))
if c.height ~= c_height and c.height > 10 then
c:relative_move(0, dpi(10), 0, 0)
end
end
end,
{description = 'decrease floating client size vertically by 10 px down', group = 'client'}
),
awful.key(
{modkey, 'Control'},
'Left',
function(c)
if c.floating and c.width > 10 then
c:relative_move(0, 0, dpi(-10), 0)
end
end,
{description = 'decrease floating client size horizontally by 10 px left', group = 'client'}
),
awful.key(
{modkey, 'Control'},
'Right',
function(c)
if c.floating then
local c_width = c.width
c:relative_move(0, 0, dpi(-10), 0)
if c.width ~= c_width and c.width > 10 then
c:relative_move(dpi(10), 0 , 0, 0)
end
end
end,
{description = 'decrease floating client size horizontally by 10 px right', group = 'client'}
)
)
return clientKeys

View file

@ -15,9 +15,9 @@ naughty.config.defaults.ontop = true
naughty.config.defaults.icon_size = dpi(32)
naughty.config.defaults.timeout = 5
naughty.config.defaults.title = 'System Notification'
naughty.config.defaults.margin = dpi(20)
naughty.config.defaults.margin = dpi(100)
naughty.config.defaults.border_width = 0
naughty.config.defaults.position = 'bottom_middle'
naughty.config.defaults.position = 'top_right'
naughty.config.defaults.shape = function(cr, w, h) gears.shape.rounded_rect(cr, w, h, dpi(6)) end
-- Apply theme variables
@ -48,7 +48,7 @@ ruled.notification.connect_signal('request::rules', function()
bg = '#ff0000',
fg = '#ffffff',
margin = dpi(16),
position = 'bottom_middle',
position = 'top_right',
implicit_timeout = 15
}
}
@ -61,7 +61,7 @@ ruled.notification.connect_signal('request::rules', function()
bg = beautiful.transparent,
fg = beautiful.fg_normal,
margin = dpi(16),
position = 'bottom_middle',
position = 'top_right',
implicit_timeout = 8
}
}
@ -74,7 +74,7 @@ ruled.notification.connect_signal('request::rules', function()
bg = beautiful.transparent,
fg = beautiful.fg_normal,
margin = dpi(16),
position = 'bottom_middle',
position = 'top_right',
implicit_timeout = 5
}
}
@ -251,10 +251,12 @@ naughty.connect_signal("request::display", function(n)
right = dpi(10),
left = dpi(10),
bottom = dpi(10),
top = dpi(5),
top = dpi(15),
widget = wibox.container.margin
},
right = dpi(100),
top = dpi(150),
widget = wibox.container.margin
}
}
-- Destroy popups if dont_disturb mode is on

View file

@ -1,4 +1,8 @@
pcall(require, "luarocks.loader")
local fennel = require("./fennel")
fennel.path = fennel.path .. ";.config/awesome/?.fnl"
table.insert(package.loaders or package.searchers, fennel.make_searcher({correlate=true}))
require("init") -- loads init.fnl
-- Standard awesome library
local gears = require("gears")
@ -21,7 +25,7 @@ local nice = require("nice")
require("awful.hotkeys_popup.keys")
require('module.notifications')
require('module.decorate-client')
-- require('module.decorate-client')
require('module.backdrop')
require('module.volume-osd')
require('module.brightness-osd')
@ -387,7 +391,7 @@ awful.screen.connect_for_each_screen(function(s)
{ -- Right widgets
layout = wibox.layout.align.horizontal,
s.myemptywidget,
s.myemptywidget,
wibox.container.margin (s.mypromptbox,dpi(25),dpi(25),0,0), -- Middle widget
s.myrightwidgets,
},
visible = true,
@ -482,7 +486,9 @@ awful.keyboard.append_global_keybindings({
-- dolphin
awful.key({ modkey, }, "d", function () awful.spawn("dolphin") end,
{description = "open dolphin file manager", group = "apps"}),
-- mpv
awful.key({ modkey, altkey }, "m", function () awful.spawn("mpv --player-operation-mode=pseudo-gui") end,
{description = "open mpv", group = "apps"}),
-- layout
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
{description = "increase master width factor", group = "layout"}),
@ -670,19 +676,25 @@ for i = 1, 9 do
)
end
clientbuttons = gears.table.join(
awful.mouse.append_global_mousebindings({
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewprev),
awful.button({ }, 5, awful.tag.viewnext),
})
client.connect_signal("request::default_mousebindings", function()
awful.mouse.append_client_mousebindings({
awful.button({ }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
c:activate { context = "mouse_click" }
end),
awful.button({ modkey }, 1, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.move(c)
c:activate { context = "mouse_click", action = "mouse_move" }
end),
awful.button({ modkey }, 3, function (c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.resize(c)
end)
)
c:activate { context = "mouse_click", action = "mouse_resize"}
end),
})
end)
-- Set keys
root.keys(globalkeys)
@ -690,29 +702,28 @@ root.keys(globalkeys)
-- {{{ Rules
-- Rules to apply to new clients (through the "manage" signal).
ruled.client.connect_signal('request::manage', function()
ruled.client.append_rule {
ruled.client.connect_signal("request::rules", function()
-- All clients will match this rule.
ruled.client.append_rule {
id = "global",
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
},
}
-- make mpv specific
ruled.client.append_rule {
-- make mpv float
id = "mpv",
rule_any = {
class = {
"mpv",
"gl",
"vlc"
"mpv"
}
},
properties = {
@ -721,53 +732,41 @@ ruled.client.connect_signal('request::manage', function()
ontop = true,
raise = true
},
}
-- ruled.client.append_rule {
-- -- Floating clients.
-- rule_any = {
-- class = {
-- "Arandr",
-- "Blender",
-- "dolphin",
-- },
-- name = {
-- "Event Tester", -- xev.
-- "remove images?" -- darktable delete window.
-- },
-- role = {
-- "AlarmWindow", -- Thunderbird's calendar.
-- "ConfigManager", -- Thunderbird's about:config.
-- "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
-- }
-- },
-- properties = { floating = true },
-- }
-- Floating clients.
ruled.client.append_rule {
id = "floating",
rule_any = {
class = {
"Arandr",
"Blender",
"dolphin",
},
name = {
"Event Tester", -- xev.
"remove images?" -- darktable delete window.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
}
},
properties = { floating = true },
}
-- ruled.client.append_rule {
-- -- Add titlebars to normal clients and dialogs
-- rule_any = { type = { "normal", "dialog" } },
-- properties = { titlebars_enabled = false},
-- }
-- ruled.client.append_rule {
-- -- Set Firefox to never have titlebars
-- rule = { class = "Firefox" },
-- properties = { requests_no_titlebar = true, titlebars_enabled = false },
-- }
-- ruled.client.append_rule {
-- -- Set Feh center
-- rule = { class = "feh" },
-- properties = {
-- placement = awful.placement.centered,
-- floating = true
-- },
-- }
-- Set Feh center
ruled.client.append_rule {
id = "feh",
rule = { class = "feh" },
properties = {
placement = awful.placement.centered,
floating = true
},
}
end)
-- }}}
awful.spawn.with_shell("mpv /home/chris/Videos/transcoded/a love letter.mp4")
-- {{{ Signals
-- Signal function to execute when a new client appears.
@ -797,7 +796,7 @@ client.connect_signal("focus", function(c) c.border_color = beautiful.border_foc
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
-- Autostart Applications
-- {{{ Autostart Applications
awful.spawn.with_shell("picom --experimental-backend")
awful.spawn.with_shell("libinput-gestures-setup start")
awful.spawn.with_shell("flameshot")
@ -807,3 +806,5 @@ awful.spawn.with_shell("/usr/lib/polkit-kde-authentication-agent-1")
awful.spawn.with_shell("emacs -daemon")
awful.spawn.with_shell("nextcloud --background")
awful.spawn.with_shell("caffeine")
-- }}}

View file

@ -30,7 +30,7 @@ local beautiful = require("beautiful")
local menubar = require("menubar")
local hotkeys_popup = require("awful.hotkeys_popup")
local ruled = require("ruled")
local nice = require("nice")
local nice = require("nice")()
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")

36
awesome/rules.fnl Normal file
View file

@ -0,0 +1,36 @@
(global awful (require "awful"))
(global beautiful (require "beautiful"))
(global keybindings (require "keys"))
(local
rules
[
;; All clients match this rule
{
:rule { }
:propertites {
:border-width beautiful.border_width
:border_color beautiful.border_normal
:focus awful.client.focus.filter
:raise true
:buttons keybindings.clientbuttons
:screen awful.screen.preferred
:placement (+ awful.placement.no_overlap awful.placement.no_offscreen)
}
}
;; floating
{
:rule_any {
:class [
"mpv"
"dolphin"
]
:role [
"pop-up"
]}
:properties {:floating true}
}
])
rules

View file

@ -131,7 +131,7 @@ theme.wibar_width = dpi(1850)
-- theme.titlebar_maximized_button_normal_active = themes_path.."default/titlebar/maximized_normal_active.png"
-- theme.titlebar_maximized_button_focus_active = themes_path.."default/titlebar/maximized_focus_active.png"
theme.wallpaper = wallpaperdir.."RoyalKing.png"
theme.wallpaper = wallpaperdir .. "RoyalKing.png"
-- You can use your own layout icons like this:
theme.layout_fairh = themes_path.."default/layouts/fairhw.png"

View file

@ -33,10 +33,10 @@ shadow = true;
# The blur radius for shadows, in pixels. (defaults to 12)
# shadow-radius = 12
shadow-radius = 12;
shadow-radius = 8;
# The opacity of shadows. (0.0 - 1.0, defaults to 0.75)
shadow-opacity = .85
shadow-opacity = .75
# The left offset for shadows, in pixels. (defaults to -15)
# shadow-offset-x = -15
@ -85,6 +85,7 @@ shadow-offset-y = 0;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'firefox'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'",
"class_g = 'slop'",
@ -97,7 +98,7 @@ shadow-exclude = [
# shadow-exclude-reg = "x10+0+0"
# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on.
#
# shadow-exclude-reg = ""
shadow-exclude-reg = "x90+0+0"
# Crop shadow of a window fully on a particular Xinerama screen to the screen.
# xinerama-shadow-crop = false