feat: change the color mode check method to gsettings portal
This commit is contained in:
parent
fc39a811c9
commit
2027c95314
4 changed files with 52 additions and 25 deletions
|
|
@ -4,34 +4,35 @@ require "nvchad.options"
|
|||
|
||||
-- auto dark mode theme
|
||||
-- (if you use this don't use the theme toggle in the editor, it may break the function)
|
||||
-- migrated to auto-dark-mode.nvim plugin
|
||||
|
||||
-- "darkman get" result to decide which color_scheme to use.
|
||||
-- if it's not installed/command error, fallback to dark scheme
|
||||
local ok, result = pcall(function()
|
||||
return vim.system({"darkman", "get"}, { text = true }):wait().stdout
|
||||
end)
|
||||
|
||||
local color_scheme
|
||||
|
||||
if ok then
|
||||
color_scheme = result
|
||||
else
|
||||
-- Fallback value in case of error
|
||||
color_scheme = "dark"
|
||||
end
|
||||
-- local ok, result = pcall(function()
|
||||
-- return vim.system({"get-current-color-mode"}, { text = true }):wait().stdout
|
||||
-- end)
|
||||
--
|
||||
-- local color_scheme
|
||||
--
|
||||
-- if ok then
|
||||
-- color_scheme = result
|
||||
-- else
|
||||
-- -- Fallback value in case of error
|
||||
-- color_scheme = "dark"
|
||||
-- end
|
||||
|
||||
-- set theme!
|
||||
-- hooray, nvchad new version supports to set theme manually!
|
||||
if string.find(color_scheme,"dark") then
|
||||
require("nvconfig").base46.theme = 'nord'
|
||||
require("base46").load_all_highlights()
|
||||
elseif string.find(color_scheme,"light") then
|
||||
require("nvconfig").base46.theme = 'onenord_light'
|
||||
require("base46").load_all_highlights()
|
||||
else
|
||||
require("nvconfig").base46.theme = 'doomchad'
|
||||
require("base46").load_all_highlights()
|
||||
end
|
||||
-- if string.find(color_scheme,"dark") then
|
||||
-- require("nvconfig").base46.theme = 'nord'
|
||||
-- require("base46").load_all_highlights()
|
||||
-- elseif string.find(color_scheme,"light") then
|
||||
-- require("nvconfig").base46.theme = 'onenord_light'
|
||||
-- require("base46").load_all_highlights()
|
||||
-- else
|
||||
-- require("nvconfig").base46.theme = 'doomchad'
|
||||
-- require("base46").load_all_highlights()
|
||||
-- end
|
||||
|
||||
-- local o = vim.o
|
||||
-- o.cursorlineopt ='both' -- to enable cursorline!
|
||||
local o = vim.o
|
||||
o.cursorlineopt ='both' -- to enable cursorline!
|
||||
|
|
|
|||
18
home/private_dot_config/nvim/lua/plugins/auto-color-mode.lua
Normal file
18
home/private_dot_config/nvim/lua/plugins/auto-color-mode.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- This should work on all platforms
|
||||
return {
|
||||
"f-person/auto-dark-mode.nvim",
|
||||
opts = {
|
||||
set_dark_mode = function()
|
||||
require("nvconfig").base46.theme = 'nord'
|
||||
require("base46").load_all_highlights()
|
||||
end,
|
||||
set_light_mode = function()
|
||||
require("nvconfig").base46.theme = 'onenord_light'
|
||||
require("base46").load_all_highlights()
|
||||
end,
|
||||
update_interval = 5000,
|
||||
fallback = "dark"
|
||||
},
|
||||
priority=1,
|
||||
lazy=false,
|
||||
}
|
||||
|
|
@ -14,11 +14,14 @@ if status is-interactive
|
|||
#starship init fish | source
|
||||
|
||||
# set theme
|
||||
if string match -q -- light (darkman get)
|
||||
if string match -q -- light (get-current-color-mode)
|
||||
fish_config theme choose "Nord Light"
|
||||
else
|
||||
fish_config theme choose "Nord"
|
||||
end
|
||||
|
||||
#thefuck --alias | source
|
||||
pay-respects fish | source
|
||||
end
|
||||
|
||||
# greeting
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
string=`gsettings get org.gnome.desktop.interface color-scheme | tr -d "'"`
|
||||
substring_to_remove="prefer-"
|
||||
result="${string//${substring_to_remove}/}"
|
||||
echo "$result"
|
||||
Loading…
Add table
Add a link
Reference in a new issue