improve media controls, merge colors, etc

This commit is contained in:
chayleaf 2023-02-26 17:41:58 +07:00
parent 01c0995f38
commit 741a5dfb18
6 changed files with 172 additions and 94 deletions

View file

@ -193,42 +193,6 @@
enabled = "fcitx5"; enabled = "fcitx5";
fcitx5.addons = with pkgs; [ fcitx5-lua fcitx5-gtk fcitx5-mozc fcitx5-configtool fcitx5-qt ]; fcitx5.addons = with pkgs; [ fcitx5-lua fcitx5-gtk fcitx5-mozc fcitx5-configtool fcitx5-qt ];
}; };
xresources.properties = {
# special colors
"*.foreground" = "#ebdadd";
"*.background" = "[75]#24101a";
"*.cursorColor" = "#ebdadd";
# black
"*.color0" = "#523b3f"; # "#3b4252";
"*.color8" = "#6b4d52"; # "#4c566a";
# red
"*.color1" = "#e66e6e";
"*.color9" = "#e66e6e";
# green
"*.color2" = "#8cbf73";
"*.color10" = "#8cbf73";
# yellow
"*.color3" = "#ebbe5f";
"*.color11" = "#ebbe5f";
# blue
"*.color4" = "#5968b3";
"*.color12" = "#5968b3";
# magenta
"*.color5" = "#a64999";
"*.color13" = "#a64999";
# cyan
"*.color6" = "#77c7c2";
"*.color14" = "#77c7c2";
# white
"*.color7" = "#f0e4e6";
"*.color15" = "#f7f0f1";
"*antialias" = true;
"*autohint" = true;
# "*fading" = 0;
# "*fadeColor" = "#6b4d52";
};
# home.file.".Xdefaults".source = /. + "/${config.home.homeDirectory}/.Xresources";
home.file.".Xdefaults".source = config.home.file."${config.home.homeDirectory}/.Xresources".source;
services.gammastep.enable = true; services.gammastep.enable = true;
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
gtk = { gtk = {

View file

@ -3,6 +3,37 @@ let
modifier = "Mod4"; modifier = "Mod4";
rofiSway = config.programs.rofi.finalPackage; rofiSway = config.programs.rofi.finalPackage;
rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; }; rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; };
audioNext = with pkgs; writeShellScript "playerctl-next" ''
${playerctl}/bin/playerctl next
PLAYER=$(${playerctl}/bin/playerctl -l | head -n 1)
# mpdris2 bug: audio wont play after a seek/skip, you have to pause-unpause
if [[ "$PLAYER" == "mpd" ]]; then
${playerctl}/bin/playerctl pause
${playerctl}/bin/playerctl position 0
${playerctl}/bin/playerctl play
fi
'';
audioPrev = with pkgs; writeShellScript "playerctl-prev" ''
# just seek if over 5 seconds into the track
POS=$(${playerctl}/bin/playerctl position)
PLAYER=$(${playerctl}/bin/playerctl -l | head -n 1)
if [ -n "$POS" ]; then
if (( $(echo "$POS > 5.01" | ${bc}/bin/bc -l) )); then
SEEK=1
fi
fi
if [ -z "$SEEK" ]; then
${playerctl}/bin/playerctl previous
else
${playerctl}/bin/playerctl position 0
fi
# mpdris2 bug: audio wont play after a seek/skip, you have to pause-unpause
if [[ "$PLAYER" == "mpd" ]]; then
${playerctl}/bin/playerctl pause
${playerctl}/bin/playerctl position 0
${playerctl}/bin/playerctl play
fi
'';
barConfig = { barConfig = {
mode = "dock"; mode = "dock";
hiddenState = "hide"; hiddenState = "hide";
@ -15,18 +46,18 @@ barConfig = {
}; };
trayOutput = "*"; trayOutput = "*";
colors = { colors = {
background = "#24101a"; background = "#${config.colors.background}";
statusline = "#ebdadd"; statusline = "#${config.colors.foreground}";
separator = "#6b4d52"; separator = "#${config.colors.brBlack}";
focusedWorkspace = { focusedWorkspace = {
border = "#782a2a"; border = "#782a2a";
background = "#782a2a"; background = "#782a2a";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
activeWorkspace = { activeWorkspace = {
border = "#913131"; border = "#913131";
background = "#913131"; background = "#913131";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
inactiveWorkspace = { inactiveWorkspace = {
border = "#472222"; border = "#472222";
@ -36,12 +67,12 @@ barConfig = {
urgentWorkspace = { urgentWorkspace = {
border = "#734545"; border = "#734545";
background = "#993d3d"; background = "#993d3d";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
bindingMode = { bindingMode = {
border = "#734545"; border = "#734545";
background = "#993d3d"; background = "#993d3d";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
}; };
}; };
@ -59,37 +90,37 @@ commonConfig = {
]; ];
colors = { colors = {
focused = { focused = {
childBorder = "#b0a3a5c0"; childBorder = "#b0a3a5${config.colors.hexAlpha}";
# background = "#24101ac0"; # background = "#${config.colors.background}${config.colors.hexAlpha}";
background = "#4c4042e0"; background = "#4c4042e0";
# border = "#24101ac0"; # border = "#${config.colors.background}${config.colors.hexAlpha}";
border = "#4c4042e0"; border = "#4c4042e0";
indicator = "#b35656"; indicator = "#b35656";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
focusedInactive = { focusedInactive = {
# background = "#24101ac0"; # background = "#${config.colors.background}${config.colors.hexAlpha}";
background = "#4c4042e0"; background = "#4c4042e0";
# border = "#24101ac0"; # border = "#${config.colors.background}${config.colors.hexAlpha}";
border = "#4c4042e0"; border = "#4c4042e0";
childBorder = "#24101ac0"; childBorder = "#${config.colors.background}${config.colors.hexAlpha}";
indicator = "#b32d2d"; indicator = "#b32d2d";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
unfocused = { unfocused = {
background = "#24101ac0"; background = "#${config.colors.background}${config.colors.hexAlpha}";
# border = "#24101ac0"; # border = "#${config.colors.background}${config.colors.hexAlpha}";
border = "#4c4042e0"; border = "#4c4042e0";
childBorder = "#24101ac0"; childBorder = "#${config.colors.background}${config.colors.hexAlpha}";
indicator = "#661a1a"; indicator = "#661a1a";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
urgent = { urgent = {
background = "#993d3d"; background = "#993d3d";
border = "#734545"; border = "#734545";
childBorder = "#734545"; childBorder = "#734545";
indicator = "#993d3d"; indicator = "#993d3d";
text = "#ebdadd"; text = "#${config.colors.foreground}";
}; };
}; };
floating.criteria = [ floating.criteria = [
@ -178,8 +209,8 @@ in
XF86AudioLowerVolume = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5"; XF86AudioLowerVolume = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5";
XF86AudioMute = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute"; XF86AudioMute = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute";
XF86AudioPlay = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; XF86AudioPlay = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
XF86AudioNext = "exec ${pkgs.playerctl}/bin/playerctl next"; XF86AudioNext = "exec ${audioNext}";
XF86AudioPrev = "exec ${pkgs.playerctl}/bin/playerctl previous"; XF86AudioPrev = "exec ${audioPrev}";
}; };
terminal = config.terminalBinX; terminal = config.terminalBinX;
}; in commonConfig // i3Config; }; in commonConfig // i3Config;
@ -275,8 +306,8 @@ in
"--locked XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5"; "--locked XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5";
"--locked XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute"; "--locked XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute";
"--locked --inhibited XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; "--locked --inhibited XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"--locked --inhibited XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; "--locked --inhibited XF86AudioNext" = "exec ${audioNext}";
"--locked --inhibited XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; "--locked --inhibited XF86AudioPrev" = "exec ${audioPrev}";
}); });
startup = commonConfig.startup ++ [ startup = commonConfig.startup ++ [
{ {
@ -355,25 +386,25 @@ in
line-uses-inside = true; line-uses-inside = true;
inside-color = "#24101ac0"; inside-color = "#${config.colors.background}${config.colors.hexAlpha}";
text-color = "#ebdadd"; text-color = "#${config.colors.foreground}";
ring-color = "#8cbf73"; # green ring-color = "#${config.colors.green}";
key-hl-color = "#6398bf"; # blue key-hl-color = "#6398bf"; # blue
bs-hl-color = "#e66e6e"; # red bs-hl-color = "#${config.colors.red}";
inside-caps-lock-color = inside-color; inside-caps-lock-color = inside-color;
text-caps-lock-color = text-color; text-caps-lock-color = text-color;
ring-caps-lock-color = "#ebbe5f"; # yellow ring-caps-lock-color = "#${config.colors.yellow}";
caps-lock-key-hl-color = key-hl-color; caps-lock-key-hl-color = key-hl-color;
caps-lock-bs-hl-color = bs-hl-color; caps-lock-bs-hl-color = bs-hl-color;
inside-clear-color = inside-color; inside-clear-color = inside-color;
text-clear-color = text-color; text-clear-color = text-color;
ring-clear-color = ring-color; # green ring-clear-color = ring-color;
inside-ver-color = inside-color; inside-ver-color = inside-color;
text-ver-color = text-color; text-ver-color = text-color;
ring-ver-color = "#a64999"; # purple ring-ver-color = "#${config.colors.magenta}";
inside-wrong-color = inside-color; inside-wrong-color = inside-color;
text-wrong-color = text-color; text-wrong-color = text-color;
@ -398,8 +429,10 @@ in
scrollbar = true; scrollbar = true;
background = transparent; background = transparent;
background-color = mkLiteral "#24101a80"; background-color =
foreground = mkLiteral "#ebdadd"; # this somehow uses different opacity
mkLiteral "#${config.colors.background}c0";
foreground = mkLiteral "#${config.colors.foreground}";
border-color = foreground; border-color = foreground;
separatorcolor = border-color; separatorcolor = border-color;
scrollbar-handle = border-color; scrollbar-handle = border-color;
@ -409,21 +442,21 @@ in
alternate-normal-background = transparent; alternate-normal-background = transparent;
alternate-normal-foreground = normal-foreground; alternate-normal-foreground = normal-foreground;
selected-normal-background = mkLiteral "#394893"; selected-normal-background = mkLiteral "#394893";
selected-normal-foreground = mkLiteral "#e66e6e"; selected-normal-foreground = mkLiteral "#${config.colors.red}";
active-background = foreground; active-background = foreground;
active-foreground = mkLiteral "#24101a"; active-foreground = mkLiteral "#${config.colors.background}";
alternate-active-background = active-background; alternate-active-background = active-background;
alternate-active-foreground = active-foreground; alternate-active-foreground = active-foreground;
selected-active-background = mkLiteral "#e66e6e"; selected-active-background = mkLiteral "#${config.colors.red}";
selected-active-foreground = mkLiteral "#394893"; selected-active-foreground = mkLiteral "#394893";
urgent-background = mkLiteral "#e66e6e"; urgent-background = mkLiteral "#${config.colors.red}";
urgent-foreground = foreground; urgent-foreground = foreground;
alternate-urgent-background = urgent-background; alternate-urgent-background = urgent-background;
alternate-urgent-foreground = urgent-foreground; alternate-urgent-foreground = urgent-foreground;
selected-urgent-background = mkLiteral "#394893"; selected-urgent-background = mkLiteral "#394893";
selected-urgent-foreground = mkLiteral "#ebbe5f"; selected-urgent-foreground = mkLiteral "#${config.colors.yellow}";
}; };
"@import" = "gruvbox-common.rasi"; "@import" = "gruvbox-common.rasi";
}; };

View file

@ -1,4 +1,4 @@
{ lib, ... }: { lib, config, ... }:
with lib; { with lib; {
options.terminals = mkOption { options.terminals = mkOption {
type = with types; listOf str; type = with types; listOf str;
@ -31,9 +31,53 @@ with lib; {
type = types.float; type = types.float;
description = "opacity (0.0-1.0)"; description = "opacity (0.0-1.0)";
}; };
hexAlpha = mkOption {
type = types.str;
description = "hex opacity (read-only)";
};
percentAlpha = mkOption {
type = types.int;
description = "opacity percentage (read-only)";
};
black = mkOption { type = types.str; description = "read-only"; };
red = mkOption { type = types.str; description = "read-only"; };
green = mkOption { type = types.str; description = "read-only"; };
yellow = mkOption { type = types.str; description = "read-only"; };
blue = mkOption { type = types.str; description = "read-only"; };
magenta = mkOption { type = types.str; description = "read-only"; };
cyan = mkOption { type = types.str; description = "read-only"; };
white = mkOption { type = types.str; description = "read-only"; };
brBlack = mkOption { type = types.str; description = "read-only"; };
brRed = mkOption { type = types.str; description = "read-only"; };
brGreen = mkOption { type = types.str; description = "read-only"; };
brYellow = mkOption { type = types.str; description = "read-only"; };
brBlue = mkOption { type = types.str; description = "read-only"; };
brMagenta = mkOption { type = types.str; description = "read-only"; };
brCyan = mkOption { type = types.str; description = "read-only"; };
brWhite = mkOption { type = types.str; description = "read-only"; };
}; };
}; };
}; };
config.colors.hexAlpha =
let hex = lib.trivial.toHexString (lib.trivial.min 255 (builtins.floor (config.colors.alpha * 256.0)));
in if (builtins.stringLength hex) == 2 then hex else "0${hex}";
config.colors.percentAlpha = builtins.floor (config.colors.alpha * 100.0);
config.colors.black = builtins.elemAt config.colors.base 0;
config.colors.red = builtins.elemAt config.colors.base 1;
config.colors.green = builtins.elemAt config.colors.base 2;
config.colors.yellow = builtins.elemAt config.colors.base 3;
config.colors.blue = builtins.elemAt config.colors.base 4;
config.colors.magenta = builtins.elemAt config.colors.base 5;
config.colors.cyan = builtins.elemAt config.colors.base 6;
config.colors.white = builtins.elemAt config.colors.base 7;
config.colors.brBlack = builtins.elemAt config.colors.base 8;
config.colors.brRed = builtins.elemAt config.colors.base 9;
config.colors.brGreen = builtins.elemAt config.colors.base 10;
config.colors.brYellow = builtins.elemAt config.colors.base 11;
config.colors.brBlue = builtins.elemAt config.colors.base 12;
config.colors.brMagenta = builtins.elemAt config.colors.base 13;
config.colors.brCyan = builtins.elemAt config.colors.base 14;
config.colors.brWhite = builtins.elemAt config.colors.base 15;
options.termShell = mkOption { options.termShell = mkOption {
type = types.submodule { type = types.submodule {
options = { options = {

View file

@ -9,7 +9,7 @@ let
}).${term}); }).${term});
color = builtins.elemAt config.colors.base; color = builtins.elemAt config.colors.base;
hex = (x: if builtins.isFunction x then (y: "#" + (x y)) else ("#" + x)); hex = (x: if builtins.isFunction x then (y: "#" + (x y)) else ("#" + x));
shell = lib.mkIf config.termShell.enable config.termShell.path; shell = lib.mkIf config.termShell.enable (lib.mkDefault config.termShell.path);
in { in {
imports = [ ./options.nix ]; imports = [ ./options.nix ];
terminalBin = getTerminalBin (builtins.head config.terminals); terminalBin = getTerminalBin (builtins.head config.terminals);
@ -35,8 +35,10 @@ in {
]; ];
foreground = "ebdadd"; foreground = "ebdadd";
background = "24101a"; background = "24101a";
alpha = 0.75; # 0.75 with opengl sway
alpha = 0.95;
}; };
programs.tmux.shell = shell;
programs.alacritty = { programs.alacritty = {
enable = supportTerminal "alacritty"; enable = supportTerminal "alacritty";
# https://github.com/alacritty/alacritty/blob/master/alacritty.yml # https://github.com/alacritty/alacritty/blob/master/alacritty.yml
@ -48,24 +50,24 @@ in {
colors.primary.background = hex config.colors.background; colors.primary.background = hex config.colors.background;
colors.primary.foreground = hex config.colors.foreground; colors.primary.foreground = hex config.colors.foreground;
colors.normal = { colors.normal = {
black = hex color 0; black = hex config.colors.black;
red = hex color 1; red = hex config.colors.red;
green = hex color 2; green = hex config.colors.green;
yellow = hex color 3; yellow = hex config.colors.yellow;
blue = hex color 4; blue = hex config.colors.blue;
magenta = hex color 5; magenta = hex config.colors.magenta;
cyan = hex color 6; cyan = hex config.colors.cyan;
white = hex color 7; white = hex config.colors.white;
}; };
colors.bright = { colors.bright = {
black = hex color 8; black = hex config.colors.brBlack;
red = hex color 9; red = hex config.colors.brRed;
green = hex color 10; green = hex config.colors.brGreen;
yellow = hex color 11; yellow = hex config.colors.brYellow;
blue = hex color 12; blue = hex config.colors.brBlue;
magenta = hex color 13; magenta = hex config.colors.brMagenta;
cyan = hex color 14; cyan = hex config.colors.brCyan;
white = hex color 15; white = hex config.colors.brWhite;
}; };
}; };
}; };
@ -89,6 +91,39 @@ in {
"xft:Symbols Nerd Font Mono:size=16" "xft:Symbols Nerd Font Mono:size=16"
]; ];
}; };
xresources.properties = lib.mkIf config.programs.urxvt.enable {
# special colors
"*.foreground" = hex config.colors.foreground;
"*.background" = "[${builtins.toString config.colors.percentAlpha}]#${config.colors.background}";
"*.cursorColor" = hex config.colors.foreground;
# black
"*.color0" = hex color 0;
"*.color8" = hex color 8;
# red
"*.color1" = hex color 1;
"*.color9" = hex color 9;
# green
"*.color2" = hex color 2;
"*.color10" = hex color 10;
# yellow
"*.color3" = hex color 3;
"*.color11" = hex color 11;
# blue
"*.color4" = hex color 4;
"*.color12" = hex color 12;
# magenta
"*.color5" = hex color 5;
"*.color13" = hex color 13;
# cyan
"*.color6" = hex color 6;
"*.color14" = hex color 14;
# white
"*.color7" = hex color 7;
"*.color15" = hex color 15;
"*antialias" = true;
"*autohint" = true;
};
home.file.".Xdefaults".source = lib.mkIf config.programs.urxvt.enable config.home.file."${config.home.homeDirectory}/.Xresources".source;
programs.foot = { programs.foot = {
enable = supportTerminal "foot"; enable = supportTerminal "foot";
server.enable = true; server.enable = true;

View file

@ -24,6 +24,8 @@
au FileType markdown set colorcolumn=73 textwidth=72 au FileType markdown set colorcolumn=73 textwidth=72
au FileType gitcommit set colorcolumn=73 au FileType gitcommit set colorcolumn=73
highlight NormalFloat guibg=NONE highlight NormalFloat guibg=NONE
au BufReadPre * set foldmethod=syntax
au BufReadPost * folddoc foldopen!
''; '';
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;

View file

@ -1,4 +1,4 @@
@define-color bg rgba(36, 16, 26, .75); /*#24101ac0;*/ @define-color bg rgba(36, 16, 26, /*.75*/ .95); /*#24101ac0;*/
@define-color blue #87e5cf; @define-color blue #87e5cf;
@define-color green #8cbf73; @define-color green #8cbf73;
@define-color yellow #ebbe5f; @define-color yellow #ebbe5f;