1
Fork 0

feat: useless feature which makes the theme change based on an env var

This commit is contained in:
Matei Adriel 2022-03-11 00:49:44 +02:00
parent 2757c649b9
commit a27b90af9e
10 changed files with 48 additions and 37 deletions

View file

@ -31,9 +31,6 @@ function M.setup()
-- Set leader -- Set leader
helpers.global("mapleader", "<Space>") helpers.global("mapleader", "<Space>")
-- Set theme
-- require('github-theme').setup({theme_style = "light", dark_float = true, transparent = true})
end end
return M return M

View file

@ -4,14 +4,16 @@ let
themes = pkgs.myThemes; themes = pkgs.myThemes;
createTheme = (theme: { createTheme = (theme: {
xdg.configFile."alacritty/themes/${theme.name}.yml".text = builtins.toJSON xdg.configFile."alacritty/themes/${theme.name}.yml".text =
(lib.attrs.recursiveUpdate theme.alacritty.settings { builtins.toJSON
import = [ "~/.config/alacritty/alacritty.yml" ]; (lib.attrsets.recursiveUpdate theme.alacritty.settings {
import = theme.alacritty.settings.import ++ [ "~/.config/alacritty/alacritty.yml" ];
}); });
}); });
createThemeConfigs = lib.lists.foldr createThemeConfigs = lib.lists.foldr
(acc: theme: lib.attrs.recursiveUpdate acc (createTheme theme)) (theme: acc: lib.attrsets.recursiveUpdate acc (createTheme theme)
)
{ } { }
themes; themes;
in in

View file

@ -11,7 +11,7 @@ let
themePlugins = lib.lists.concatMap (theme: theme.neovim.plugins) themes; themePlugins = lib.lists.concatMap (theme: theme.neovim.plugins) themes;
loadTheme = (theme: '' loadTheme = (theme: ''
if currentTheme = "${theme.name}" then if currentTheme == "${theme.name}" then
${theme.neovim.theme} ${theme.neovim.theme}
vim.g.lualineTheme = ${theme.neovim.lualineTheme} vim.g.lualineTheme = ${theme.neovim.lualineTheme}
@ -19,12 +19,12 @@ let
''); '');
loadThemes = '' loadThemes = ''
lua << EOF
local currentTheme = os.getenv("THEME"); local currentTheme = os.getenv("THEME");
${pkgs.myHelpers.mergeLines (lib.lists.forEach themes loadTheme)}; ${pkgs.myHelpers.mergeLines (lib.lists.forEach themes loadTheme)};
EOF
''; '';
in in
{ {
home-manager.users.adrielus.programs.neovim = { home-manager.users.adrielus.programs.neovim = {
@ -32,6 +32,7 @@ in
package = pkgs.neovim-nightly; package = pkgs.neovim-nightly;
extraConfig = '' extraConfig = ''
${loadThemes}
luafile ${config-nvim}/init.lua luafile ${config-nvim}/init.lua
''; '';
@ -57,7 +58,7 @@ in
]; ];
plugins = with pkgs.vimPlugins; plugins = with pkgs.vimPlugins;
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; themePlugins + [ with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; themePlugins ++ [
config-nvim # my neovim config config-nvim # my neovim config
nvim-lspconfig # configures lsps for me nvim-lspconfig # configures lsps for me
nvim-autopairs # close pairs for me nvim-autopairs # close pairs for me

View file

@ -24,5 +24,5 @@
# Render git repo using gource # Render git repo using gource
"git-render" = "gource -f -s 1 -c 4 --key"; "git-render" = "gource -f -s 1 -c 4 --key";
alacritty = "alacritty --config-file $XDG_CONFIG_HOME/alacritty/themes/$THEME.yml"; alacritty = "alacritty --config-file ~/.config/alacritty/themes/$THEME.yml";
} }

View file

@ -1,6 +1,7 @@
{ ... }: { ... }:
with import ../../../secrets.nix; with import ../../../secrets.nix;
let let
theme = "github-dark";
variables = { variables = {
# Configure github cli # Configure github cli
GITHUB_USERNAME = "Mateiadrielrafael"; GITHUB_USERNAME = "Mateiadrielrafael";
@ -10,7 +11,10 @@ let
EDITOR = "nvim"; EDITOR = "nvim";
# Sets the current theme used by all programs # Sets the current theme used by all programs
THEME = "github-light"; THEME = theme;
# Common command for launching alacritty with the correct theme
# LAUNCH_ALACRITTY = "alacritty --config-file ~/.config/alacritty/themes/$THEME.yml";
}; };
in in
{ {

View file

@ -1,7 +1,11 @@
{-# LANGUAGE BlockArguments #-} {-# LANGUAGE BlockArguments #-}
import System.Environment
import System.Process
import Control.Monad (join) import Control.Monad (join)
import Data.Function ((&)) import Data.Function ((&))
import XMonad import XMonad
import XMonad.Actions.SpawnOn import XMonad.Actions.SpawnOn
import XMonad.Config (defaultConfig) import XMonad.Config (defaultConfig)
@ -71,6 +75,9 @@ main =
manageWorkspaces manageWorkspaces
] ]
spawnTerminal = do
spawn "fish -c 'alacritty --config-file ~/.config/alacritty/themes/$THEME.yml'"
myTerminal = "alacritty" myTerminal = "alacritty"
myBrowser = "google-chrome-stable" myBrowser = "google-chrome-stable"
@ -78,9 +85,8 @@ main =
keymap = keymap =
[ ("M-p", spawn "rofi -show run"), [ ("M-p", spawn "rofi -show run"),
("M-g", spawn myBrowser), ("M-g", spawn myBrowser),
("M-d", spawn "Discord"), ("M-s", spawnTerminal),
("M-s", spawn "slack"), ("M-d", spawn "Discord")
("M-r", spawn "ksysgurad")
] ]
uniformBorder = join $ join $ join Border uniformBorder = join $ join $ join Border
@ -95,8 +101,9 @@ main =
startup :: X () startup :: X ()
startup = do startup = do
spawn "xwallpaper --zoom ./picutres/portal.png" spawn "xwallpaper --zoom ./background.jpg"
-- spawn "Discord" -- spawn "Discord"
-- spawn "google-chrome-stable" -- spawn "google-chrome-stable"
-- spawn "alacritty" -- spawn "alacritty"

View file

@ -1,5 +1,5 @@
{ lib, ... }: { { lib, ... }: {
mergeLines = (lines: lib.foldr mergeLines = (lines: lib.lists.foldr
(a: b: '' (a: b: ''
${a} ${a}
${b} ${b}

View file

@ -11,7 +11,6 @@
, fish-theme-dangerous , fish-theme-dangerous
, oh-my-fish , oh-my-fish
, githubNvimTheme , githubNvimTheme
, vim-extra-plugins
, vim-plugin-arpeggio , vim-plugin-arpeggio
, telescope-file-browser-nvim , telescope-file-browser-nvim
, sddm-theme-chili , sddm-theme-chili

View file

@ -1,29 +1,32 @@
variant: { pkgs, ... }: { { variant, transparency ? 1 }: { pkgs, ... }:
let
githubTheme = pkgs.myVimPlugins.githubNvimTheme; # github theme for neovim
in
{
name = "github-${variant}"; name = "github-${variant}";
neovim = { neovim = {
plugins = [ plugins = [ pkgs.vimExtraPlugins.github-nvim-theme ];
pkgs.myVimPlugins.github-nvim-theme # github theme for neovim
];
theme = '' theme = ''
require('github-theme').setup({theme_style = "light", dark_float = true, transparent = true}) require('github-theme').setup({theme_style = "${variant}", dark_float = true, transparent = true})
''; '';
lualineTheme = "github"; lualineTheme = "github";
}; };
tmux.path = "${pkgs.githubNvimTheme}/terminal/tmux/github_light.conf"; tmux.path = "${githubTheme}/terminal/tmux/github_${variant}.conf";
alacritty.settings = { alacritty.settings = {
import = [ "${pkgs.githubNvimTheme}/terminal/alacritty/github_light.yml" ]; import = [ "${githubTheme}/terminal/alacritty/github_${variant}.yml" ];
window = { window = {
padding = { padding = {
x = 8; x = 8;
y = 8; y = 8;
}; };
# transparent bg:) gtk_theme_variant = if variant == "light" then "light" else "dark";
background_opacity = 0.8;
gtk_theme_variant = "light";
}; };
# transparent bg:)
background_opacity = transparency;
}; };
} }

View file

@ -1,9 +1,7 @@
{ pkgs }: { pkgs, lib, ... }:
let githubVariant = import ./githubVariant.nix; let githubVariant = import ./githubVariant.nix;
in in
lib.map (theme: pkgs.callPackage theme { }) [ lib.lists.map (theme: pkgs.callPackage theme { }) [
githubVariant (githubVariant { variant = "light"; })
"light" (githubVariant { variant = "dark"; transparency = 0.8; })
githubVariant
"dark"
] ]