Update fennel + awesomewm config

+ Bumped fennel: 0.8.1 -> 0.9.2.
+ Use luajit for awesomewm + fennel.
+ Add barebones awesomewm fennel config (more to come later).
This commit is contained in:
Henrik Lissner 2021-07-05 13:05:47 -04:00
parent f894614a37
commit b9d3279034
3 changed files with 173 additions and 4 deletions

111
config/awesome/init.fnl Normal file
View file

@ -0,0 +1,111 @@
(local gears (require :gears))
(local awful (require :awful))
(local naughty (require :naughty))
(require :awful.autofocus)
(local wincmd (require :commands.window))
(local tagcmd (require :commands.tag))
(local pa (require :utils.pulseaudio))
(local input (require :utils.input))
(fn initialize [bindings]
;; 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)
(let [preset { :timeout 0 :bg "#000000" :fg "#ff0000" :max_height 1080 }]
(when awesome.startup_errors
(naughty.notify {:preset preset
:title "Oops, there were errors during startup!"
:text awesome.startup_errors}))
(var in-error false)
(awesome.connect_signal
"debug::error"
(fn []
;; Make sure we don't go into an endless error loop
(when (not in-error)
(set in-error true)
(naughty.notify {:preset preset
:title "Oops, an error happened!"
:text (tostring err)})
(naughty.notify {:preset preset
:title "Oops, an error happened!"
:text (tostring err)})
(set in-error false)))))
(root.keys bindings.global-keys)
(naughty.notify {:text "Glorious fennel"})
(gears.wallpaper.set "#282c34"))
(local
bindings
{
:global-keys
(gears.table.join
(input.key-group
"awesome"
[[:mod] :s hotkeys_popup.show_help "show help"]
[[:mod :shift] :r awesome.restart "reload config"]
)
(input.key-group
"exec"
[[:mod] :space (fn [] (awful.util.spawn "rofi -show run")) "app launcher"]
[[:mod] :e (fn [] (awful.util.spawn "emacsclient -c -n -e '(switch-to-buffer nil)'")) "emacs"]
[[:mod] :v (fn []
(let [option "gopass ls --flat"
prompt "rofi -dmenu -p pass"
action "xargs --no-run-if-empty gopass show -c"
cmd (.. option " | " prompt " | " action)]
(awful.spawn.easy_async_with_shell cmd (fn []))))
"secret vault"]
[[:mod] :Return (fn [] (awful.spawn "xst")) "open terminal"]
[[] :XF86AudioMute pa.toggle-muted "⏼ audio muted"]
[[] :XF86AudioMicMute pa.toggle-mic-mute "⏼ mic muted"]
[[] :XF86AudioRaiseVolume (fn [] (pa.adjust-volume 5)) "raise volume"]
[[] :XF86AudioLowerVolume (fn [] (pa.adjust-volume -5)) "lower volume"]
)
(input.key-group
"client"
[[:mod] :h (fn [] (awful.client.focus.bydirection :left)) "focus left"]
[[:mod] :j (fn [] (awful.client.focus.bydirection :down)) "focus down"]
[[:mod] :k (fn [] (awful.client.focus.bydirection :up)) "focus up"]
[[:mod] :l (fn [] (awful.client.focus.bydirection :right)) "focus right"]
[[:mod] :n (fn [] (awful.client.focus.byidx 1)) "focus next"]
[[:mod] :p (fn [] (awful.client.focus.byidx -1)) "focus previous"]
[[:mod :shift] :j (fn [] (awful.client.swap.byidx 1)) "swap next with previous"]
[[:mod :shift] :k (fn [] (awful.client.swap.byidx -1)) "swap next with previous"]
)
)
:client-keys
(gears.table.join
(input.key-group
"client"
[[:mod] :n wincmd.minimize "minimize"]
[[:mod] :t wincmd.toggle-ontop "⏼ keep on top"]
[[:mod] :m wincmd.toggle-maximized "⏼ maximize"]
[[:mod] :f wincmd.toggle-fullscreen "⏼ fullscreen"]
[[:mod :ctrl] :space awful.client.floating.toggle "⏼ floating"]
[[:mod :ctrl] :Return wincmd.move-to-master "move to master"]
[[:mod :ctrl] :m wincmd.toggle-maximize-vertical "⏼ max vertically"]
[[:mod :shift] :m wincmd.toggle-maximize-horizontal "⏼ max horizontally"]
[[:mod :shift] :c wincmd.close "close"]
))
:client-buttons
(gears.table.join
(input.mousebind [] input.left-click client.mouse-raise)
(input.mousebind [:mod] input.left-click client.mouse-drag-move)
(input.mousebind [:mod] input.right-click client.mouse-drag-resize)
)
})
;;
(initialize bindings)

View file

@ -0,0 +1,57 @@
{ options, config, lib, pkgs, ... }:
with lib;
with lib.my;
let cfg = config.modules.desktop.awesomewm;
configDir = config.dotfiles.configDir;
in {
options.modules.desktop.awesomewm = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
nixpkgs.overlays = [
(self: super: with super; {
awesome = super.awesome.override { luaPackages = super.luajitPackages; };
})
];
environment.systemPackages = with pkgs; [
luajit
my.fennel
];
services = {
picom.enable = true;
redshift.enable = true;
xserver = {
enable = true;
displayManager = {
lightdm.enable = true;
# lightdm.greeters.mini.enable = true;
};
windowManager.awesome.enable = true;
};
};
home.configFile = {
"awesome" = { source = "${configDir}/awesome"; recursive = true; };
"awesome/rc.lua".text = ''
-- File was auto-generated by nix. Do not touch!
-- Load system fennel
package.path = package.path .. ";${pkgs.my.fennel}/?.lua"
local fennel = require("fennel")
debug.traceback = fennel.traceback
-- Then load our awesomewm config
fennel.path = fennel.path .. ";.config/awesome/?.fnl"
table.insert(package.loaders or package.searchers, fennel.makeSearcher({
correlate = true,
useMetadata = true
}))
require("init")
'';
};
};
}

View file

@ -1,13 +1,13 @@
{ lib, stdenv, luajit, my, ... }:
let name = "fennel";
version = "0.8.1";
version = "0.9.2";
in stdenv.mkDerivation {
inherit name version;
src = fetchTarball {
url = "https://fennel-lang.org/downloads/${name}-${version}.tar.gz";
sha256 = "0hzxnsgq4yqsvzkndplcllvq3j8cw45npqyrqa2ww8jv5abr183i";
sha256 = "0p9zr2vb9gq877advb5jvybx6dmqzmxqh4i7yzdr7fwvz7xzd2jv";
};
buildInputs = [
@ -16,10 +16,11 @@ in stdenv.mkDerivation {
phases = "installPhase";
installPhase = ''
mkdir -p $out/bin
mkdir -p $out $out/bin
cp $src/fennel $out/bin/fennel
cp $src/fennel.lua $out/fennel.lua
chmod +x $out/bin/fennel
sed -i 's%^#!/usr/bin/env lua$%#!${luajit}/bin/lua%' $out/bin/fennel
sed -i 's%^#!/usr/bin/env lua$%#!${luajit}/bin/luajit%' $out/bin/fennel
'';
meta = {