restructure

This commit is contained in:
♥ Minnie ♥ 2023-05-15 21:11:30 +08:00
parent 5fe6a629f3
commit e54745b952
28 changed files with 997 additions and 203 deletions

View file

@ -0,0 +1,30 @@
{ inputs, pkgs, ... }:
{
imports = [ ];
nixpkgs.overlays = [
(final: prev: {
xmobar = inputs.xmobar-config.packages.${pkgs.system}.xmobar-config;
})
];
home.packages = with pkgs; [
dmenu
feh
unstable.wezterm
xmobar
];
xsession.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ./xmonad/xmonad-config/src/xmonad.hs;
};
home.file.".xinitrc".source = ./xinitrc;
xdg.configFile = {
wezterm = { source = ./wezterm; recursive = true; };
};
}

View file

@ -0,0 +1,36 @@
[colors]
background = '#1d2021'
foreground = '#d4be98'
selection_bg = '#d4be98'
selection_fg = '#3c3836'
cursor_bg = '#d4be98'
cursor_fg = '#1d2021'
cursor_border = '#d4be98'
ansi = [
'#1d2021',
'#ea6962',
'#a9b665',
'#d8a657',
'#7daea3',
'#d3869b',
'#89b482',
'#d4be98',
]
brights = [
'#7c6f64',
'#ea6962',
'#a9b665',
'#d8a657',
'#7daea3',
'#d3869b',
'#89b482',
'#d4be98',
]
[colors.indexed]
[metadata]
name = 'gruvbox_material_dark_hard'
origin_url = 'https://gist.github.com/theoriginalstove/89aa16316a756721816886398080dbd6'

View file

@ -0,0 +1,113 @@
-- Pull in the wezterm API
local wezterm = require 'wezterm'
local act = wezterm.action
-- This table will hold the configuration.
local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- This function returns the suggested title for a tab.
-- It prefers the title that was set via `tab:set_title()`
-- or `wezterm cli set-tab-title`, but falls back to the
-- title of the active pane in that tab.
function tab_title(tab_info)
local title = tab_info.tab_title
-- if the tab title is explicitly set, take that
if title and #title > 0 then
return title
end
-- Otherwise, use the title from the active pane
-- in that tab
return tab_info.active_pane.title
end
wezterm.on(
'format-tab-title',
function(tab, tabs, panes, config, hover, max_width)
local title = tab_title(tab)
return { { Text = ' ' .. title .. '' }, }
end
)
-- Do not check for or show window with update information
config.check_for_updates = false
config.show_update_window = false
-- Font
config.font = wezterm.font 'Fira Code'
config.font_size = 10.0
-- Color scheme
config.color_scheme = 'gruvbox_material_dark_hard'
-- Padding
config.window_padding = {
left = 20,
right = 20,
top = 20,
bottom = 0,
}
-- Tab bar appearance
config.use_fancy_tab_bar = false
config.enable_tab_bar = true
config.hide_tab_bar_if_only_one_tab = false
config.tab_bar_at_bottom = true
config.tab_max_width = 24
config.show_tab_index_in_tab_bar = false
-- Colors
config.colors = {
tab_bar = {
background = '#1d2021',
-- style tabs
active_tab = { bg_color = '#1d2021', fg_color = '#d3869b', intensity = 'Bold', italic = false, },
inactive_tab = { bg_color = '#1d2021', fg_color = '#7daea3', intensity = 'Bold', italic = false, },
inactive_tab_hover = { bg_color = '#1d2021', fg_color = '#7daea3', intensity = 'Bold', italic = false, },
new_tab = { bg_color = '#1d2021', fg_color = '#7c6f64', intensity = 'Bold', italic = false, },
new_tab_hover = { bg_color = '#1d2021', fg_color = '#7c6f64', intensity = 'Bold', italic = false, },
}
}
-- Key Assignments
config.disable_default_key_bindings = true
config.keys = {}
for i = 1, 8 do
-- CTRL+ALT + number to activate that tab
table.insert(config.keys, {
key = tostring(i),
mods = 'CTRL|ALT',
action = act.ActivateTab(i - 1),
})
end
config.keys = {
-- Tabs
{ key = 't', mods = 'ALT', action = act.SpawnTab 'CurrentPaneDomain', },
{ key = 'w', mods = "ALT|CTRL", action = act.CloseCurrentTab { confirm = false }, },
-- Panes
{ key = 'v', mods = 'ALT', action = act.SplitVertical { domain = 'CurrentPaneDomain' }, },
{ key = 'h', mods = 'ALT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' }, },
{ key = 'x', mods = "ALT", action = act.CloseCurrentPane { confirm = false }, },
-- Navigation
{ key = 'LeftArrow', mods = 'ALT', action = act.ActivateTabRelative(-1) },
{ key = 'RightArrow', mods = 'ALT', action = act.ActivateTabRelative(1) },
{ key = 'DownArrow', mods = 'ALT', action = act.ActivatePaneDirection 'Next', },
{ key = 'UpArrow', mods = 'ALT', action = act.ActivatePaneDirection 'Prev', },
-- Copy Mode / Clipboard
{ key = 'X', mods = 'CTRL', action = act.ActivateCopyMode, },
{ key = 'C', mods = 'CTRL', action = act.CopyTo 'ClipboardAndPrimarySelection', },
{ key = 'V', mods = 'CTRL', action = act.PasteFrom 'Clipboard', },
}
return config

View file

@ -0,0 +1,10 @@
#/bin/bash
# Setup our monitors
xrandr --output HDMI-A-0 --mode 1920x1080 --output DisplayPort-0 --mode 2560x1440 --right-of HDMI-A-0
# Apply our wallpaper
feh --bg-scale /etc/nixos/assets/chinatown.png
# Launch our window manager
exec xmonad

View file

@ -0,0 +1,80 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1683560683,
"narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "006c75898cf814ef9497252b022e91c946ba8e17",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"haskell-flake": {
"locked": {
"lastModified": 1684069239,
"narHash": "sha256-1nPdY5KasmGwwtuKv7OKCLCZC3wlAE+hJWwKZRBAluo=",
"owner": "srid",
"repo": "haskell-flake",
"rev": "b8ccbf305e720e3483d7b983aeda61326169226a",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "haskell-flake",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1684120848,
"narHash": "sha256-gIwJ5ac1FwZEkCRwjY+gLwgD4G1Bw3Xtr2jr2XihMPo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0cb867999eec4085e1c9ca61c09b72261fa63bb4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1682879489,
"narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"haskell-flake": "haskell-flake",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,46 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { self', pkgs, ... }: {
# Typically, you just want a single project named "default". But
# multiple projects are also possible, each using different GHC version.
haskellProjects.default = {
# If you have a .cabal file in the root, this option is determined
# automatically. Otherwise, specify all your local packages here.
packages.xmobar-config.root = ./.;
# The base package set representing a specific GHC version.
# By default, this is pkgs.haskellPackages.
# You may also create your own. See https://haskell.flake.page/package-set
# basePackages = pkgs.haskellPackages;
# Dependency overrides go here. See https://haskell.flake.page/dependency
# source-overrides = { };
# overrides = self: super: { };
# devShell = {
# # Enabled by default
# enable = true;
#
# # Programs you want to make available in the shell.
# # Default programs can be disabled by setting to 'null'
# tools = hp: { fourmolu = hp.fourmolu; ghcid = null; };
#
# hlsCheck.enable = true;
# };
};
# haskell-flake doesn't set the default package, but you can do it here.
packages.default = self'.packages.xmobar-config;
};
};
}

View file

@ -0,0 +1,47 @@
import Xmobar
-- | Configuration
config :: Config
config = defaultConfig
-- general settings
{ font = "Fira Code Semi Bold 9"
, additionalFonts = [ "Symbols Nerd Font 2048-em 24" ]
, bgColor = bg1
, fgColor = fg0
, position = Static { xpos = 1920, ypos = 0, width = 2560, height = 24 }
-- commands to run
, commands =
[ Run $ XPropertyLog "_XMONAD_LOG_1"
, Run $ Com "uname" ["-r","-s"] "" 0
, Run $ Date "%a %b %_d %Y <fc=#d8a657>%H:%M:%S</fc>" "date" 10
, Run $ Weather "YPJT"
[ "-t", "Temp: <fc=#d3869b><tempC>C</fc> <fc=#7c6f64>|</fc> Wind: <fc=#a9b665><windKmh>km/h</fc> <fc=#7c6f64>|</fc> Humidity: <fc=#e78a4e><rh>%</fc>" ]
18000
]
-- format our bar
, sepChar = "%"
, alignSep = "}{"
, template = "<hspace=6/><fn=1>\59255</fn> <fc=#a9b665>%uname%</fc> <fc=#7c6f64>|</fc>%_XMONAD_LOG_1%}{%YPJT% <fc=#7c6f64>|</fc> %date%<hspace=6/>"
}
-- | Gruvbox material
bg0, bg1, fg0, fg1, red, orange, yellow, green, aqua, blue, purple :: String
-- backgrounds
bg0 = "#1d2021"
bg1 = "#282828"
-- foregrounds
fg0 = "#d4be98"
fg1 = "#ddc7a1"
-- greys
grey0 = "#7c6f64"
-- colors
red = "#ea6962"
orange = "#e78a4e"
yellow = "#d8a658"
green = "#a9b665"
aqua = "#89b482"
blue = "#7daea3"
purple = "#d3869b"
main :: IO ()
main = configFromArgs config >>= xmobar

View file

@ -0,0 +1,18 @@
cabal-version: 3.0
name: xmobar-config
version: 0.1.0.0
synopsis: A Minimalistic Text Based Status Bar
description: my xmobar configuration
license: BSD-3-Clause
author: sajenim
maintainer: its.jassy@pm.me
build-type: Simple
executable xmobar-top
main-is: xmobar-top.hs
hs-source-dirs: src
ghc-options: -Wall -threaded
build-depends: base,
xmobar
default-language: Haskell2010

View file

@ -0,0 +1,80 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1683560683,
"narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "006c75898cf814ef9497252b022e91c946ba8e17",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"haskell-flake": {
"locked": {
"lastModified": 1684069239,
"narHash": "sha256-1nPdY5KasmGwwtuKv7OKCLCZC3wlAE+hJWwKZRBAluo=",
"owner": "srid",
"repo": "haskell-flake",
"rev": "b8ccbf305e720e3483d7b983aeda61326169226a",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "haskell-flake",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1684120848,
"narHash": "sha256-gIwJ5ac1FwZEkCRwjY+gLwgD4G1Bw3Xtr2jr2XihMPo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0cb867999eec4085e1c9ca61c09b72261fa63bb4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1682879489,
"narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"haskell-flake": "haskell-flake",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,46 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { self', pkgs, ... }: {
# Typically, you just want a single project named "default". But
# multiple projects are also possible, each using different GHC version.
haskellProjects.default = {
# If you have a .cabal file in the root, this option is determined
# automatically. Otherwise, specify all your local packages here.
packages.xmonad-config.root = ./.;
# The base package set representing a specific GHC version.
# By default, this is pkgs.haskellPackages.
# You may also create your own. See https://haskell.flake.page/package-set
# basePackages = pkgs.haskellPackages;
# Dependency overrides go here. See https://haskell.flake.page/dependency
# source-overrides = { };
# overrides = self: super: { };
# devShell = {
# # Enabled by default
# enable = true;
#
# # Programs you want to make available in the shell.
# # Default programs can be disabled by setting to 'null'
# tools = hp: { fourmolu = hp.fourmolu; ghcid = null; };
#
# hlsCheck.enable = true;
# };
};
# haskell-flake doesn't set the default package, but you can do it here.
packages.default = self'.packages.xmonad-config;
};
};
}

View file

@ -0,0 +1,154 @@
-- Base
import XMonad
import System.Exit
import qualified XMonad.StackSet as W
-- Actions
import XMonad.Actions.CycleWS
-- Hooks
import XMonad.Hooks.EwmhDesktops
-- Layouts
import XMonad.Layout.ThreeColumns
-- Layout modifiers
import XMonad.Layout.Spacing
import XMonad.Layout.Renamed
import XMonad.Layout.NoBorders
-- Utilities
import XMonad.Util.EZConfig (additionalKeysP)
-- xmobar dependencies
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Util.Loggers
-- | Configuration
myTerminal = "wezterm"
myModMask = mod4Mask
myBorderWidth = 5
myNormalBorderColor = "#282828"
myFocusedBorderColor = "#282828"
myWorkspaces = ["code", "chat", "web", "games", "misc"]
-- | Keybindings
myKeys =
-- launching and killing programs
[ ("M-n" , spawn myTerminal ) -- %! Launch terminal
, ("M-e" , spawn "dmenu_run" ) -- %! Launch dmenu
, ("M-C-w" , kill ) -- %! Close the focused window
-- layouts
, ("M-<Space>" , sendMessage NextLayout ) -- %! Rotate through the available layout algorithms
-- move focus up or down the window stack
, ("M-<Down>" , windows W.focusDown ) -- %! Move focus to the next window
, ("M-<Up>" , windows W.focusUp ) -- %! Move focus to the previous window
, ("M-<Return>" , windows W.focusMaster ) -- %! Move focus to the master window
-- modifying the window order
, ("M-S-<Down>" , windows W.swapDown ) -- %! Swap the focused window with the next window
, ("M-S-<Up>" , windows W.swapUp ) -- %! Swap the focused window with the previous window
, ("M-S-<Return>" , windows W.swapMaster ) -- %! Swap the focused window with the master window
-- resizing the master/slave ratio
, ("M-<Page_Up>" , sendMessage Expand ) -- %! Expand the master area
, ("M-<Page_Down>" , sendMessage Shrink ) -- %! Shrink the master area
-- number of windows in the master area
, ("M-S-<Page_Up>" , sendMessage (IncMasterN 1) ) -- %! Increase the number of windows in the master area
, ("M-S-<Page_Down>", sendMessage (IncMasterN (-1)) ) -- %! Decrease the number of windows in the master area
-- floating layer support
, ("M-t" , withFocused $ windows . W.sink ) -- %! Push window back into tiling
-- workspace navigation
, ("M-<Right>" , moveTo Next hiddenWS ) -- %! Move focus to the next hidden workspace
, ("M-<Left>" , moveTo Prev hiddenWS ) -- %! Move focus to the previous hidden workspace
-- move window to workspace
, ("M-S-<Right>" , shiftTo Next hiddenWS ) -- %! Move focused window to the next hidden workspace
, ("M-S-<Left)" , shiftTo Prev hiddenWS ) -- %! Move focused window to the previous hidden workspace
-- move focus up or down the screen stack
, ("M-<End>" , nextScreen ) -- %! Move focus to the next screen
, ("M-<Home>" , prevScreen ) -- %! Move focus to the previous screen
-- move windows between screens
, ("M-S-<End>" , shiftNextScreen ) -- %! Move focused window to the next screen
, ("M-S-<Home>" , shiftPrevScreen ) -- %! Move focused window to the previous screen
-- quit, or restart
, ("M-S-q" , io exitSuccess ) -- %! Quit xmonad
]
-- | Layouts
myLayout = tiled ||| threeCol ||| full
where
-- Add a configurable amount of space around windows.
gaps = spacingRaw False (Border 50 50 50 50) True (Border 10 10 10 10) True
-- Our layouts
tiled = renamed [Replace "Spacing Tiled"] . gaps $ Tall nmaster delta ratio
threeCol = renamed [Replace "Spacing Three Column"] . gaps $ ThreeColMid nmaster delta ratio
full = renamed [Replace "Fullscreen"] $ noBorders Full
-- Layout settings
nmaster = 1 -- Default number of windows in the master pane
ratio = 1/2 -- Default proportion of screen occupied by master pane
delta = 3/100 -- Percent of screen to increment by when resizing panes
-- | Xmobar
xmobarTop = statusBarPropTo "_XMONAD_LOG_1" "xmobar-top" (pure ppTop)
ppTop :: PP
ppTop = def
{ ppSep = grey0 " | "
, ppTitleSanitize = xmobarStrip
-- workspace labels
, ppCurrent = purple . wrap " " ""
, ppVisible = blue . wrap " " ""
, ppHidden = grey0 . wrap " " ""
, ppHiddenNoWindows = grey0 . wrap " " ""
, ppUrgent = red . wrap " " ""
-- misc
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
where
formatFocused = wrap (grey0 "") (grey0 " ") . purple . ppWindow
formatUnfocused = wrap (grey0 "") (grey0 " ") . blue . ppWindow
-- | Windows should have *some* title, which should not not exceed a
-- sane length.
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
-- | Gruvbox material
bg0, bg1, fg0, fg1, red, orange, yellow, green, aqua, blue, purple :: String -> String
-- backgrounds
bg0 = xmobarColor "#1d2021" ""
bg1 = xmobarColor "#282828" ""
-- foregrounds
fg0 = xmobarColor "#d4be98" ""
fg1 = xmobarColor "#ddc7a1" ""
-- greys
grey0 = xmobarColor "#7c6f64" ""
-- colors
red = xmobarColor "#ea6962" ""
orange = xmobarColor "#e78a4e" ""
yellow = xmobarColor "#d8a658" ""
green = xmobarColor "#a9b665" ""
aqua = xmobarColor "#89b482" ""
blue = xmobarColor "#7daea3" ""
purple = xmobarColor "#d3869b" ""
-- | The main function
main :: IO ()
main = xmonad
. ewmhFullscreen
. ewmh
. withEasySB (xmobarTop) defToggleStrutsKey
$ myConfig
myConfig = def
{ modMask = myModMask
, layoutHook = myLayout
, terminal = myTerminal
, borderWidth = myBorderWidth
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
, workspaces = myWorkspaces
} `additionalKeysP` myKeys

View file

@ -0,0 +1,19 @@
cabal-version: 3.0
name: xmonad-config
version: 0.1.0.0
synopsis: A tiling window manager
description: my xmonad configuration
license: BSD-3-Clause
author: sajenim
maintainer: its.jassy@pm.me
build-type: Simple
executable xmonad-config
main-is: xmonad.hs
hs-source-dirs: src
ghc-options: -Wall
build-depends: base,
xmonad,
xmonad-contrib
default-language: Haskell2010