diff --git a/README.md b/README.md index 88cabb6..d212107 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,14 @@ Expected configuration: * Fedora Silverblue as host * Nix with home-manager for tools and software. + +## Dark and Light themes + +Neovim and Kitty are configured to follow Gnome's dark and light theme +changes. + +By default they are initially light and in case of changes, they will start +to match the correct preferences. + +To make this work, [night theme switcher](https://extensions.gnome.org/extension/2236/night-theme-switcher/) +extension is needed and configured to use `scripts/sunrise.sh` and `scripts/sunset.sh` as "run commands". diff --git a/bat/config b/bat/config new file mode 100644 index 0000000..db721e2 --- /dev/null +++ b/bat/config @@ -0,0 +1,2 @@ +--italic-text='always' +--theme=OneHalfDark diff --git a/install.sh b/install.sh index c2eaf9a..263fbc3 100755 --- a/install.sh +++ b/install.sh @@ -30,8 +30,9 @@ echo "==[host] Installing Home Manager" nix-channel --add https://nixos.org/channels/nixpkgs-unstable nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update + nix-shell '' -A install -workspace_link home.nix .config/home-manager/home.nix +workspace_link nix/home.nix .config/home-manager/home.nix echo "==[host] Installing Home Manager packages" home-manager switch diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 25db8fd..ad468b6 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -4,59 +4,20 @@ italic_font Liga Operator Mono SSm BookItalic Nerd Font bold_italic_font Liga Operator Mono SSm MediumItalic Nerd Font disable_ligatures never +hide_window_decorations yes wayland_titlebar_color system -# https://github.com/sainnhe/edge-extras/blob/master/kitty/edge-light.conf -foreground #4b505b -background #fafafa - -# black -color0 #4b505b -color8 #4b505b - -# red -color1 #d05858 -color9 #d05858 - -# green -color2 #608e32 -color10 #608e32 - -# yellow -color3 #be7e05 -color11 #be7e05 - -# blue -color4 #5079be -color12 #5079be -url_color #5079be - -# magenta -color5 #b05ccc -color13 #b05ccc - -# cyan -color6 #3a8b84 -color14 #3a8b84 - -# white -color7 #fafafa -color15 #fafafa +# Theme, default to light +include themes/rose-pine-dawn.conf +include theme.conf # Tab Bar tab_bar_style separator tab_separator "" tab_title_template " {fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{'/'.join(tab.active_oldest_wd.split('/')[-2:])} " -tab_bar_background #b05ccc -inactive_tab_foreground #fafafa -inactive_tab_background #b05ccc -active_tab_background #fafafa -active_tab_foreground #4b505b - # Layouts enabled_layouts fat:bias=70;full_size=1;mirrored=false,tall:bias=50;full_size=1;mirrored=false,stack -active_border_color #b05ccc # Window movement map ctrl+left neighboring_window left diff --git a/kitty/themes/rose-pine-dawn.conf b/kitty/themes/rose-pine-dawn.conf new file mode 100644 index 0000000..397c9a8 --- /dev/null +++ b/kitty/themes/rose-pine-dawn.conf @@ -0,0 +1,56 @@ +## name: Rosé Pine Dawn +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine-dawn.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #575279 +background #faf4ed +selection_foreground #575279 +selection_background #dfdad9 + +cursor #cecacd +cursor_text_color #575279 + +url_color #907aa9 + +active_tab_foreground #575279 +active_tab_background #f2e9e1 +inactive_tab_foreground #9893a5 +inactive_tab_background #faf4ed + +active_border_color #286983 +inactive_border_color #dfdad9 + +# black +color0 #f2e9e1 +color8 #9893a5 + +# red +color1 #b4637a +color9 #b4637a + +# green +color2 #286983 +color10 #286983 + +# yellow +color3 #ea9d34 +color11 #ea9d34 + +# blue +color4 #56949f +color12 #56949f + +# magenta +color5 #907aa9 +color13 #907aa9 + +# cyan +color6 #d7827e +color14 #d7827e + +# white +color7 #575279 +color15 #575279 + diff --git a/kitty/themes/rose-pine-moon.conf b/kitty/themes/rose-pine-moon.conf new file mode 100644 index 0000000..4d4de88 --- /dev/null +++ b/kitty/themes/rose-pine-moon.conf @@ -0,0 +1,56 @@ +## name: Rosé Pine Moon +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine-moon.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #e0def4 +background #232136 +selection_foreground #e0def4 +selection_background #44415a + +cursor #56526e +cursor_text_color #e0def4 + +url_color #c4a7e7 + +active_tab_foreground #e0def4 +active_tab_background #393552 +inactive_tab_foreground #6e6a86 +inactive_tab_background #232136 + +active_border_color #3e8fb0 +inactive_border_color #44415a + +# black +color0 #393552 +color8 #6e6a86 + +# red +color1 #eb6f92 +color9 #eb6f92 + +# green +color2 #3e8fb0 +color10 #3e8fb0 + +# yellow +color3 #f6c177 +color11 #f6c177 + +# blue +color4 #9ccfd8 +color12 #9ccfd8 + +# magenta +color5 #c4a7e7 +color13 #c4a7e7 + +# cyan +color6 #ea9a97 +color14 #ea9a97 + +# white +color7 #e0def4 +color15 #e0def4 + diff --git a/kitty/themes/rose-pine.conf b/kitty/themes/rose-pine.conf new file mode 100644 index 0000000..575c06b --- /dev/null +++ b/kitty/themes/rose-pine.conf @@ -0,0 +1,56 @@ +## name: Rosé Pine +## author: mvllow +## license: MIT +## upstream: https://github.com/rose-pine/kitty/blob/main/dist/rose-pine.conf +## blurb: All natural pine, faux fur and a bit of soho vibes for the classy minimalist + +foreground #e0def4 +background #191724 +selection_foreground #e0def4 +selection_background #403d52 + +cursor #524f67 +cursor_text_color #e0def4 + +url_color #c4a7e7 + +active_tab_foreground #e0def4 +active_tab_background #26233a +inactive_tab_foreground #6e6a86 +inactive_tab_background #191724 + +active_border_color #31748f +inactive_border_color #403d52 + +# black +color0 #26233a +color8 #6e6a86 + +# red +color1 #eb6f92 +color9 #eb6f92 + +# green +color2 #31748f +color10 #31748f + +# yellow +color3 #f6c177 +color11 #f6c177 + +# blue +color4 #9ccfd8 +color12 #9ccfd8 + +# magenta +color5 #c4a7e7 +color13 #c4a7e7 + +# cyan +color6 #ebbcba +color14 #ebbcba + +# white +color7 #e0def4 +color15 #e0def4 + diff --git a/home.nix b/nix/home.nix similarity index 85% rename from home.nix rename to nix/home.nix index bbf070b..301a0ad 100644 --- a/home.nix +++ b/nix/home.nix @@ -28,6 +28,7 @@ tmux jq fd + fzf # Nodejs nodejs_20 @@ -46,18 +47,28 @@ # Shell zsh shfmt + + # Lua + stylua ]; # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. home.file = { - "~/.tmux.conf".source = tmux/tmux.conf; - "~/.ssh/authorized_keys".source = ssh/authorized_keys; - "${config.xdg.configHome}/starship.toml".source = starship/starship.toml; - "${config.xdg.configHome}/kitty.conf".source = kitty/kitty.conf; + "~/.tmux.conf".source = ../tmux/tmux.conf; + "~/.ssh/authorized_keys".source = ../ssh/authorized_keys; + "${config.xdg.configHome}/starship.toml".source = ../starship/starship.toml; + "${config.xdg.configHome}/bat" = { + recursive = true; + source = ../bat; + }; + "${config.xdg.configHome}/kitty" = { + recursive = true; + source = ../kitty; + }; "${config.xdg.configHome}/nvim" = { recursive = true; - source = ./nvim; + source = ../nvim; }; }; @@ -100,14 +111,6 @@ }; }; - programs.bat = { - enable = true; - config = { - theme = "OneHalfLight"; - italic-text = "always"; - }; - }; - programs.starship = { enable = true; }; diff --git a/nvim/init.vim b/nvim/init.vim index aac7e00..91f6244 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -15,8 +15,8 @@ Plug 'ojroques/vim-oscyank' Plug 'tpope/vim-obsession' Plug 'tmux-plugins/vim-tmux-focus-events' " Look +Plug 'rose-pine/neovim', {'as': 'rose-pine', 'tag': 'v1.*'} Plug 'nvim-lualine/lualine.nvim' -Plug 'sainnhe/edge' Plug 'Yggdroot/indentLine' Plug 'koenverburg/peepsight.nvim' Plug 'norcalli/nvim-colorizer.lua' @@ -168,17 +168,14 @@ set number set cursorline set hlsearch " highlight all results set signcolumn=number " always show git diff column -set background=light -let g:edge_enable_italic = 1 -let g:edge_background = 'hard' -let g:edge_diagnostic_line_highlight = 1 -let g:edge_better_performance = 1 -colorscheme edge + +""" Theme configuration +lua require('theme') lua << END require('lualine').setup({ options = { - theme = 'edge', + theme = 'rose-pine', section_separators = {'', ''}, component_separators = {'', ''}, icons_enabled = true, diff --git a/nvim/lua/theme.lua b/nvim/lua/theme.lua new file mode 100644 index 0000000..a1fdd29 --- /dev/null +++ b/nvim/lua/theme.lua @@ -0,0 +1,56 @@ +-- Configure theme +require("rose-pine").setup({ + variant = "auto", -- auto, main, moon, or dawn + dark_variant = "moon", -- main, moon, or dawn + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + }, + + styles = { + bold = true, + italic = true, + transparency = false, + }, +}) +vim.cmd("colorscheme rose-pine") +vim.o.background = "light" + +local debounce = function(ms, fn) + local running = false + return function() + if running then + return + end + vim.defer_fn(function() + running = false + end, ms) + running = true + vim.schedule(fn) + end +end + +-- Create a job to detect current gnome color scheme and set background +local Job = require("plenary.job") +local set_background = function() + local j = Job:new({ command = "gsettings", args = { "get", "org.gnome.desktop.interface", "color-scheme" } }) + j:sync() + if j:result()[1] == "'default'" then + vim.o.background = "light" + else + vim.o.background = "dark" + end +end + +-- Call imidiatly to set initially +set_background() + +-- Listen for SIGUSR1 signal to update background +local group = vim.api.nvim_create_augroup("BackgroundWatch", { clear = true }) +vim.api.nvim_create_autocmd("Signal", { + pattern = "SIGUSR1", + callback = debounce(500, set_background), + group = group, +}) diff --git a/scripts/sunrise.sh b/scripts/sunrise.sh new file mode 100755 index 0000000..d16b328 --- /dev/null +++ b/scripts/sunrise.sh @@ -0,0 +1,14 @@ +#!/bin/env bash +CONFIG_DIR=$(dirname $(dirname "$(realpath $0)")) + +# Kitty terminal +echo "include themes/rose-pine-dawn.conf" >$HOME/.config/kitty/theme.conf +kill -SIGUSR1 $(pidof kitty) + +# Neovim +kill -SIGUSR1 $(pidof nvim) + +# Bat +sed -i "s/--theme=.*/--theme=OneHalfLight/g" ${CONFIG_DIR}/bat/config + +home-manager switch diff --git a/scripts/sunset.sh b/scripts/sunset.sh new file mode 100755 index 0000000..db62a0b --- /dev/null +++ b/scripts/sunset.sh @@ -0,0 +1,14 @@ +#!/bin/env bash +CONFIG_DIR=$(dirname $(dirname "$(realpath $0)")) + +# Kitty terminal +echo "include themes/rose-pine-moon.conf" >$HOME/.config/kitty/theme.conf +kill -SIGUSR1 $(pidof kitty) + +# Neovim +kill -SIGUSR1 $(pidof nvim) + +# Bat +sed -i "s/--theme=.*/--theme=OneHalfDark/g" ${CONFIG_DIR}/bat/config + +home-manager switch