added comments for casual readers
This commit is contained in:
23
autoload.lua
23
autoload.lua
@@ -1,22 +1,22 @@
|
|||||||
local hyprRoot
|
-- Use global HyprRoot to extrappolate modules
|
||||||
local modules
|
local modules = HyprRoot .. "/modules"
|
||||||
|
|
||||||
if os.getenv("HYPRLAND_ROOT") then
|
|
||||||
hyprRoot = os.getenv("HYPRLAND_ROOT")
|
|
||||||
else
|
|
||||||
hyprRoot = os.getenv("Home") .. "/.config/hypr"
|
|
||||||
end
|
|
||||||
|
|
||||||
modules = hyprRoot .. "/modules"
|
|
||||||
|
|
||||||
|
-- Proccess to find all files ending in ".lua" in the modules directory,
|
||||||
|
-- returning in alphabetical order. Directories are excluded and subdirectories
|
||||||
|
-- in the module directory are also searched.
|
||||||
local p = io.popen('find -L "' .. modules .. '" -name "*.lua" -type f | sort')
|
local p = io.popen('find -L "' .. modules .. '" -name "*.lua" -type f | sort')
|
||||||
|
-- If p is empty or the command fails (modules dir doesnt exist), return no modules
|
||||||
if not p then
|
if not p then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- for every line in p stdout
|
||||||
for path in p:lines() do
|
for path in p:lines() do
|
||||||
|
-- Touple to call the file
|
||||||
local ok, error = pcall(dofile, path)
|
local ok, error = pcall(dofile, path)
|
||||||
|
-- If the file cannot be called (syntax error, doesn't exist, etc.)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
-- Notify the user with the information
|
||||||
hl.notification.create({
|
hl.notification.create({
|
||||||
text = "autoload: " .. path .. "\n" .. tostring(error),
|
text = "autoload: " .. path .. "\n" .. tostring(error),
|
||||||
timeout = 8000,
|
timeout = 8000,
|
||||||
@@ -24,3 +24,6 @@ for path in p:lines() do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- When all files have been called, kill hanging function
|
||||||
|
p:close()
|
||||||
|
|||||||
11
flake.nix
11
flake.nix
@@ -10,15 +10,21 @@
|
|||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
wrappers,
|
wrappers,
|
||||||
|
# @ inputs passes through the inputs set, allowing you to call inputs.inputname
|
||||||
} @ inputs: let
|
} @ inputs: let
|
||||||
|
# Hard code system for ease of use, hyprland only supports x86_64-linux anyway iirc
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
|
||||||
|
# Initialise pkgs
|
||||||
pkgs = import nixpkgs {inherit system;};
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
|
||||||
|
# Set of pacakges that hyprland depends on
|
||||||
runtimePkgs = with pkgs; [
|
runtimePkgs = with pkgs; [
|
||||||
foot
|
foot
|
||||||
waybar
|
waybar
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Defined function so that makeOverridable knows what options exist
|
||||||
mkWrapper = {
|
mkWrapper = {
|
||||||
pkgs,
|
pkgs,
|
||||||
package,
|
package,
|
||||||
@@ -29,10 +35,15 @@
|
|||||||
inherit pkgs package runtimePkgs env flags;
|
inherit pkgs package runtimePkgs env flags;
|
||||||
}));
|
}));
|
||||||
in {
|
in {
|
||||||
|
# Allows runtimePkgs to be accessed and manipulated in consuming flake (like the dendritic config)
|
||||||
|
# This isn't used for the tutorial but it is in my primary config
|
||||||
lib.runtimePkgs.${system} = runtimePkgs;
|
lib.runtimePkgs.${system} = runtimePkgs;
|
||||||
|
|
||||||
|
# Define default pacakge
|
||||||
packages.${system} = {
|
packages.${system} = {
|
||||||
|
# Make the default pacakge ovveridable
|
||||||
default = pkgs.lib.makeOverridable mkWrapper {
|
default = pkgs.lib.makeOverridable mkWrapper {
|
||||||
|
# Sane defaults
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
package = pkgs.hyprland;
|
package = pkgs.hyprland;
|
||||||
runtimePkgs = runtimePkgs;
|
runtimePkgs = runtimePkgs;
|
||||||
|
|||||||
25
hyprland.lua
25
hyprland.lua
@@ -1,12 +1,33 @@
|
|||||||
|
-- Process handle that returns stdout for the "hostname" command
|
||||||
local handle = io.popen("hostname")
|
local handle = io.popen("hostname")
|
||||||
|
|
||||||
|
-- Global variable, accessible in all other called files
|
||||||
Hostname = "default"
|
Hostname = "default"
|
||||||
|
|
||||||
|
-- If "hostname" command returned something
|
||||||
if handle then
|
if handle then
|
||||||
|
-- Set result to first line of output
|
||||||
local result = handle:read("*l")
|
local result = handle:read("*l")
|
||||||
|
-- Kill process
|
||||||
handle:close()
|
handle:close()
|
||||||
|
|
||||||
|
-- If the first line contains characters
|
||||||
if result then
|
if result then
|
||||||
Hostname = result:gsub("%s+", "") -- "HACKSTATION"
|
-- Set global variable and substitute any whitespace characters for nothing
|
||||||
|
Hostname = result:gsub("%s+", "") -- This removes spaces, newlines, tabs, etc.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pcall(dofile, os.getenv("HYPRLAND_ROOT") .. "/autoload.lua")
|
-- This differs from the video. In order to make it so that the config
|
||||||
|
-- still runs with an unset HYPRLAND_ROOT variable, it makes more sense to call
|
||||||
|
-- os.getenv in this file, and have HyprRoot be a global variable like Hostname
|
||||||
|
|
||||||
|
HyprRoot = os.getenv("HOME") .. "/.config/hypr"
|
||||||
|
|
||||||
|
-- If the HYPRLAND_ROOT var is set, use it, if not, use the default config location
|
||||||
|
if os.getenv("HYPRLAND_ROOT") then
|
||||||
|
HyprRoot = os.getenv("HYPRLAND_ROOT")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Call the autoloader using the config root location
|
||||||
|
pcall(dofile, HyprRoot .. "/autoload.lua")
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
-- Super + v launches foot
|
||||||
hl.bind("SUPER + v", hl.dsp.exec_cmd("foot"))
|
hl.bind("SUPER + v", hl.dsp.exec_cmd("foot"))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- Run the "waybar" command on startup
|
||||||
hl.on("hyprland.start", function()
|
hl.on("hyprland.start", function()
|
||||||
hl.exec_cmd("waybar")
|
hl.exec_cmd("waybar")
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user