mirror of
https://github.com/ellmau/nixos.git
synced 2025-12-19 09:29:36 +01:00
Add Xmonad options and base config in homemanager
This commit is contained in:
parent
ae484f8222
commit
556c51df18
@ -21,6 +21,8 @@ with lib; {
|
||||
DPI setting for the xserver
|
||||
'';
|
||||
};
|
||||
xserver.enable = mkEnableOption "enable X server";
|
||||
xmonad.enable = mkEnableOption "enable xmonad";
|
||||
i3.enable = mkEnableOption "enable i3";
|
||||
};
|
||||
config = let
|
||||
@ -39,21 +41,20 @@ with lib; {
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
elss.users.x11.enable =
|
||||
if cfg.i3.enable
|
||||
then true
|
||||
else false;
|
||||
# cfg.xserver.enable = cfg.i3.enable;
|
||||
elss.users.x11.enable = cfg.xserver.enable || cfg.xmonad.enable;
|
||||
|
||||
elss.networking.useNetworkManager = true;
|
||||
|
||||
services = {
|
||||
xserver = mkIf cfg.i3.enable {
|
||||
xserver = mkIf cfg.xserver.enable {
|
||||
enable = true;
|
||||
dpi = cfg.dpi;
|
||||
displayManager.lightdm = {
|
||||
enable = true;
|
||||
greeters.gtk.cursorTheme.size = cfg.greeterCursorsize;
|
||||
};
|
||||
windowManager.i3 = {
|
||||
windowManager.i3 = mkIf cfg.i3.enable {
|
||||
enable = true;
|
||||
extraPackages = with pkgs; [
|
||||
rofi # launcher
|
||||
@ -81,6 +82,8 @@ with lib; {
|
||||
bluetooth.enable = true;
|
||||
};
|
||||
|
||||
security.pam.services.lightdm.enableGnomeKeyring = true;
|
||||
|
||||
services.blueman.enable = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
22
modules/xmonad.nix
Normal file
22
modules/xmonad.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
config = let
|
||||
cfg = config.elss.graphical.xmonad;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
elss.graphical.xserver.enable = true;
|
||||
services = {
|
||||
xserver = {
|
||||
windowManager.xmonad = {
|
||||
enable = true;
|
||||
enableContribAndExtras = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
47
users/ellmau/conf/xmonad/flake.nix
Normal file
47
users/ellmau/conf/xmonad/flake.nix
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
description = "basic tool setup flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
nixpkgs-unstable,
|
||||
flake-utils,
|
||||
flake-utils-plus,
|
||||
...
|
||||
} @ inputs:
|
||||
{}
|
||||
// (flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
unstable = import nixpkgs-unstable {
|
||||
inherit system;
|
||||
};
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in rec {
|
||||
devShell = pkgs.mkShell {
|
||||
name = "xmonad";
|
||||
nativeBuildInputs = [
|
||||
# add packages here, like
|
||||
# pkgs.clingo
|
||||
(pkgs.ghc.withPackages
|
||||
(haskellPackages: [
|
||||
haskellPackages.dbus
|
||||
haskellPackages.monad-logger
|
||||
haskellPackages.hostname
|
||||
haskellPackages.xmonad
|
||||
haskellPackages.xmonad-contrib
|
||||
]))
|
||||
pkgs.haskell-language-server
|
||||
];
|
||||
};
|
||||
}
|
||||
));
|
||||
}
|
||||
81
users/ellmau/conf/xmonad/xmonad.hs
Normal file
81
users/ellmau/conf/xmonad/xmonad.hs
Normal file
@ -0,0 +1,81 @@
|
||||
module Main where
|
||||
|
||||
import Data.Ratio
|
||||
import XMonad hiding ((|||))
|
||||
import XMonad.Hooks.FadeInactive
|
||||
import XMonad.Hooks.FadeWindows
|
||||
import XMonad.Hooks.EwmhDesktops
|
||||
import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Hooks.ManageHelpers
|
||||
import XMonad.Hooks.StatusBar
|
||||
import XMonad.Util.EZConfig
|
||||
import Network.HostName (getHostName)
|
||||
-- Imports for Polybar --
|
||||
import qualified Codec.Binary.UTF8.String as UTF8
|
||||
import qualified DBus as D
|
||||
import qualified DBus.Client as D
|
||||
import XMonad.Hooks.DynamicLog
|
||||
|
||||
main :: IO ()
|
||||
main' :: D.Client -> IO ()
|
||||
main = mkDbusClient >>= main'
|
||||
|
||||
main' dbus = do
|
||||
hostname <- io $ getHostName
|
||||
xmonad . docks . ewmhFullscreen . ewmh $ def
|
||||
{ terminal = "alacritty"
|
||||
, logHook = polybarLogHook dbus
|
||||
}
|
||||
|
||||
mkDbusClient :: IO D.Client
|
||||
mkDbusClient = do
|
||||
dbus <- D.connectSession
|
||||
D.requestName dbus (D.busName_ "org.xmonad.log") opts
|
||||
return dbus
|
||||
where
|
||||
opts = [D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
|
||||
|
||||
-- Emit a DBus signal on log updates
|
||||
dbusOutput :: D.Client -> String -> IO ()
|
||||
dbusOutput dbus str =
|
||||
let opath = D.objectPath_ "/org/xmonad/Log"
|
||||
iname = D.interfaceName_ "org.xmonad.Log"
|
||||
mname = D.memberName_ "Update"
|
||||
signal = D.signal opath iname mname
|
||||
body = [D.toVariant $ UTF8.decodeString str]
|
||||
in D.emit dbus $ signal { D.signalBody = body }
|
||||
|
||||
polybarHook :: D.Client -> PP
|
||||
polybarHook dbus =
|
||||
let wrapper c s | s /= "NSP" = wrap ("%{F" <> c <> "} ") " %{F-}" s
|
||||
| otherwise = mempty
|
||||
blue = "#2E9AFE"
|
||||
gray = "#7F7F7F"
|
||||
orange = "#ea4300"
|
||||
purple = "#9058c7"
|
||||
red = "#722222"
|
||||
in def { ppOutput = dbusOutput dbus
|
||||
, ppCurrent = wrapper blue
|
||||
, ppVisible = wrapper gray
|
||||
, ppUrgent = wrapper orange
|
||||
, ppHidden = wrapper gray
|
||||
, ppHiddenNoWindows = wrapper red
|
||||
, ppTitle = shorten 100 . wrapper purple
|
||||
}
|
||||
|
||||
fadeHook :: Rational -> Rational -> X ()
|
||||
fadeHook act inact = fadeOutLogHook $ fadeAllBut exceptions act inact
|
||||
where exceptions = isFullscreen
|
||||
<||> className =? "firefox"
|
||||
<||> className =? "Chromium-browser"
|
||||
|
||||
fadeAllBut :: Query Bool -> Rational -> Rational -> Query Rational
|
||||
fadeAllBut qry amt inact = do isInactive <- isUnfocused
|
||||
isQry <- qry
|
||||
if isQry
|
||||
then return 1
|
||||
else if isInactive
|
||||
then return inact
|
||||
else return amt
|
||||
|
||||
polybarLogHook dbus = fadeHook 0.95 0.75 <+> dynamicLogWithPP (polybarHook dbus)
|
||||
Loading…
x
Reference in New Issue
Block a user