From f75d294a5b1ef159351e9c440d1842adc87a63d7 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Wed, 15 Jan 2025 22:44:59 -0500 Subject: [PATCH] Add light/dark mode toggle using xsettingsd --- bin/swap_mode.sh | 17 ++++ home/.wezterm.lua | 202 +++++++++++++++++++++++----------------------- home/.xinitrc | 1 + home/.xsettingsd | 1 + 4 files changed, 120 insertions(+), 101 deletions(-) create mode 100755 bin/swap_mode.sh create mode 100644 home/.xsettingsd diff --git a/bin/swap_mode.sh b/bin/swap_mode.sh new file mode 100755 index 0000000..c324b3e --- /dev/null +++ b/bin/swap_mode.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Script for changing between light and dark modes +mode=$(grep "light_mode = " ~/.wezterm.lua | cut -d "=" -f 2 | tr -d " ") +if [ "$mode" = "true" ]; then + echo "Swapping to dark mode" + sed -i -e "s/local light_mode =.*/local light_mode = false/" ~/.wezterm.lua + sed -i -e 's@Net/ThemeName.*@Net/ThemeName "Orchis-Grey-Dark"@' ~/.xsettingsd + sed -i -e "s/light.rasi/dark.rasi/" $HOME/.config/rofi/config.rasi +else + echo "Swapping to light mode" + sed -i -e "s/local light_mode =.*/local light_mode = true/" ~/.wezterm.lua + sed -i -e 's@Net/ThemeName.*@Net/ThemeName "Orchis-Grey-Light"@' ~/.xsettingsd + sed -i -e "s/dark.rasi/light.rasi/" $HOME/.config/rofi/config.rasi +fi + +killall -HUP xsettingsd diff --git a/home/.wezterm.lua b/home/.wezterm.lua index 60b0bd8..19c8d53 100644 --- a/home/.wezterm.lua +++ b/home/.wezterm.lua @@ -10,114 +10,114 @@ local config = wezterm.config_builder() config.enable_tab_bar = false config.font = wezterm.font("FiraCode Nerd Font Mono") config.font_size = 9 -local light_mode = false +local light_mode = true local home = os.getenv("HOME") -if light_mode then - config.colors = { - -- The default text color - foreground = "#4F5e68", - -- The default background color - background = "#F0EDEC", +--if light_mode then +config.colors = { + -- The default text color + foreground = "#4F5e68", + -- The default background color + background = "#F0EDEC", - -- Overrides the cell background color when the current cell is occupied by the - -- cursor and the cursor style is set to Block - cursor_bg = "#2c363c", - -- Overrides the text color when the current cell is occupied by the cursor - cursor_fg = "#F0EDEC", - -- Specifies the border color of the cursor when the cursor style is set to Block, - -- or the color of the vertical or horizontal bar when the cursor style is set to - -- Bar or Underline. - cursor_border = "#2c363c", + -- Overrides the cell background color when the current cell is occupied by the + -- cursor and the cursor style is set to Block + cursor_bg = "#2c363c", + -- Overrides the text color when the current cell is occupied by the cursor + cursor_fg = "#F0EDEC", + -- Specifies the border color of the cursor when the cursor style is set to Block, + -- or the color of the vertical or horizontal bar when the cursor style is set to + -- Bar or Underline. + cursor_border = "#2c363c", - -- the foreground color of selected text - selection_fg = "#F0edec", - -- the background color of selected text - selection_bg = "#2c363c", + -- the foreground color of selected text + selection_fg = "#F0edec", + -- the background color of selected text + selection_bg = "#2c363c", - -- The color of the scrollbar "thumb"; the portion that represents the current viewport - scrollbar_thumb = "#222222", + -- The color of the scrollbar "thumb"; the portion that represents the current viewport + scrollbar_thumb = "#222222", - -- The color of the split lines between panes - split = "#444444", + -- The color of the split lines between panes + split = "#444444", - ansi = { - "#F0EDEC", - "#A8334C", - "#4F6C31", - "#944927", - "#286486", - "#88507D", - "#3B8992", - "#2C363C", - }, - brights = { + ansi = { + "#F0EDEC", + "#A8334C", + "#4F6C31", + "#944927", + "#286486", + "#88507D", + "#3B8992", + "#2C363C", + }, + brights = { - "#CFC1BA", - "#94253E", - "#3F5A22", - "#803D1C", - "#1D5573", - "#7B3B70", - "#2B747C", - "#4F5E68", - }, - } - config.window_background_opacity = 0.95 - local f = io.open(home .. "/.config/nvim/light_mode", "w") - assert(f) - f:close() -else - config.colors = { - -- The default text color - foreground = "#8e8e8e", - -- The default background color - background = "#191919", - - -- Overrides the cell background color when the current cell is occupied by the - -- cursor and the cursor style is set to Block - cursor_bg = "#BBBBBB", - -- Overrides the text color when the current cell is occupied by the cursor - cursor_fg = "#191919", - -- Specifies the border color of the cursor when the cursor style is set to Block, - -- or the color of the vertical or horizontal bar when the cursor style is set to - -- Bar or Underline. - cursor_border = "#BBBBBB", - - -- the foreground color of selected text - selection_fg = "#191919", - -- the background color of selected text - selection_bg = "#BBBBBB", - - -- The color of the scrollbar "thumb"; the portion that represents the current viewport - scrollbar_thumb = "#222222", - - -- The color of the split lines between panes - split = "#444444", - - ansi = { - "#191919", - "#DE6E7C", - "#819B69", - "#B77E64", - "#6099C0", - "#B279A7", - "#66A5AD", - "#BBBBBB", - }, - brights = { - "#3d3839", - "#E8838F", - "#8BAE68", - "#D68C67", - "#61ABDA", - "#CF86C1", - "#65B8C1", - "#8e8e8e", - }, - } - config.window_background_opacity = 0.85 - os.remove(home .. "/.config/nvim/light_mode") -end + "#CFC1BA", + "#94253E", + "#3F5A22", + "#803D1C", + "#1D5573", + "#7B3B70", + "#2B747C", + "#4F5E68", + }, +} +config.window_background_opacity = 0.95 +--local f = io.open(home .. "/.config/nvim/light_mode", "w") +--assert(f) +--f:close() +--else +-- config.colors = { +-- -- The default text color +-- foreground = "#8e8e8e", +-- -- The default background color +-- background = "#191919", +-- +-- -- Overrides the cell background color when the current cell is occupied by the +-- -- cursor and the cursor style is set to Block +-- cursor_bg = "#BBBBBB", +-- -- Overrides the text color when the current cell is occupied by the cursor +-- cursor_fg = "#191919", +-- -- Specifies the border color of the cursor when the cursor style is set to Block, +-- -- or the color of the vertical or horizontal bar when the cursor style is set to +-- -- Bar or Underline. +-- cursor_border = "#BBBBBB", +-- +-- -- the foreground color of selected text +-- selection_fg = "#191919", +-- -- the background color of selected text +-- selection_bg = "#BBBBBB", +-- +-- -- The color of the scrollbar "thumb"; the portion that represents the current viewport +-- scrollbar_thumb = "#222222", +-- +-- -- The color of the split lines between panes +-- split = "#444444", +-- +-- ansi = { +-- "#191919", +-- "#DE6E7C", +-- "#819B69", +-- "#B77E64", +-- "#6099C0", +-- "#B279A7", +-- "#66A5AD", +-- "#BBBBBB", +-- }, +-- brights = { +-- "#3d3839", +-- "#E8838F", +-- "#8BAE68", +-- "#D68C67", +-- "#61ABDA", +-- "#CF86C1", +-- "#65B8C1", +-- "#8e8e8e", +-- }, +-- } +-- config.window_background_opacity = 0.85 +-- os.remove(home .. "/.config/nvim/light_mode") +--end config.keys = { { key = "j", mods = "CTRL|SHIFT", action = wezterm.action.DecreaseFontSize }, diff --git a/home/.xinitrc b/home/.xinitrc index 67cc62f..657bd2f 100644 --- a/home/.xinitrc +++ b/home/.xinitrc @@ -51,6 +51,7 @@ xrandr | grep "2560x1440" && dock.sh || mobile.sh xinput --set-prop "TPPS/2 IBM TrackPoint" "libinput Accel Speed" 1.0 xinput --set-prop "TPPS/2 IBM TrackPoint" "libinput Accel Profile Enabled" 0 1 +exec xsettingsd & exec sxhkd & exec mpd & exec mpdnotif.sh & diff --git a/home/.xsettingsd b/home/.xsettingsd new file mode 100644 index 0000000..20b10b4 --- /dev/null +++ b/home/.xsettingsd @@ -0,0 +1 @@ +Net/ThemeName "Orchis-Grey-Dark"