diff --git a/curacao/options.nix b/curacao/options.nix index a941a5f..6bed395 100644 --- a/curacao/options.nix +++ b/curacao/options.nix @@ -6,6 +6,13 @@ x11_screens = [ "HDMI-1-0" "eDP1" ]; maxVideoHeight = 1440; numlock = true; + phasesBrightness = { + enable = true; + backlight = "intel_backlight"; + jour = 40000; + crepuscule = 10000; + nuit = 1; + }; }; dev = { docker = true; diff --git a/hm/scripts/crepuscule b/hm/scripts/crepuscule deleted file mode 100755 index bedc04e..0000000 --- a/hm/scripts/crepuscule +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# FIXME - -if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ] -then - echo 10000 | sudo tee /sys/class/backlight/intel_backlight/brightness -elif [ "$(cat /etc/hostname)" = "pindakaas.geoffrey.frogeye.fr" ] -then - echo 3000 | sudo tee /sys/class/backlight/edp-backlight/brightness -fi -automatrop -e base16_scheme=solarized-dark --tags color diff --git a/hm/scripts/jour b/hm/scripts/jour deleted file mode 100755 index eb086d5..0000000 --- a/hm/scripts/jour +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# FIXME - -if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ] -then - echo 40000 | sudo tee /sys/class/backlight/intel_backlight/brightness -elif [ "$(cat /etc/hostname)" = "pindakaas.geoffrey.frogeye.fr" ] -then - echo 3500 | sudo tee /sys/class/backlight/edp-backlight/brightness -fi -automatrop -e base16_scheme=solarized-light --tags color diff --git a/hm/scripts/nuit b/hm/scripts/nuit deleted file mode 100755 index 5f409ec..0000000 --- a/hm/scripts/nuit +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# FIXME - -if [ "$(cat /etc/hostname)" = "curacao.geoffrey.frogeye.fr" ] -then - echo 1 | sudo tee /sys/class/backlight/intel_backlight/brightness -elif [ "$(cat /etc/hostname)" = "pindakaas.geoffrey.frogeye.fr" ] -then - echo 700 | sudo tee /sys/class/backlight/edp-backlight/brightness -fi -automatrop -e base16_scheme=solarized-dark --tags color diff --git a/hm/style.nix b/hm/style.nix index b29c368..a98707b 100644 --- a/hm/style.nix +++ b/hm/style.nix @@ -1,14 +1,21 @@ -{ pkgs, config, fetchFromGitHub, ... }: +{ pkgs, config, lib, ... }: let # Currently last commit in https://github.com/danth/stylix/pull/194 stylix = builtins.fetchTarball "https://github.com/willemml/stylix/archive/2ed2b0086b41d582aca26e083c19c0e47c8991e3.tar.gz"; + polarityFile = "${config.xdg.stateHome}/theme_polarity"; + polarity = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light"; + phases = [ + { command = "jour"; polarity = "light"; } + { command = "crepuscule"; polarity = "dark"; } + { command = "nuit"; polarity = "dark"; } + ]; + cfg = config.frogeye.desktop.phasesBrightness; in { imports = [ (import stylix).homeManagerModules.stylix ]; stylix = { - # FIXME Changeable at runtime - base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-dark.yaml"; + base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${polarity}.yaml"; image = builtins.fetchurl { url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png"; sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93"; @@ -30,10 +37,32 @@ in }; }; + # Setting a custom base16 theme via nixvim: + # - Is required so nixvim works + # - For the rest only works on dark polarity, use the colorscheme otherwise... shrug + programs.nixvim.colorschemes.base16.colorscheme = "solarized-${polarity}"; + # Fix https://nix-community.github.io/home-manager/index.html#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal # home.packages = [ pkgs.dconf ]; dconf.enable = false; # Otherwise standalone home-manager complains it can't find /etc/dbus-1/session.conf on Arch. # Symlinking it to /usr/share/dbus-1/session.conf goes further but not much. - + # TODO Use xbacklight instead (pindakaas doesn't seem to support it OOTB) + home.packages = map + (phase: (pkgs.writeShellApplication { + name = "${phase.command}"; + text = (lib.optionalString cfg.enable '' + echo ${builtins.toString (builtins.getAttr phase.command cfg)} | sudo tee /sys/class/backlight/${cfg.backlight}/brightness + '') + '' + echo ${phase.polarity} > ${polarityFile} + if command -v home-manager + then + home-manager switch + else + sudo nixos-rebuild switch + fi + ''; + }) + ) + phases; } diff --git a/options.nix b/options.nix index 6e7bf15..a503abd 100644 --- a/options.nix +++ b/options.nix @@ -17,6 +17,13 @@ description = "Maximum video height in pixel the machine can reasonably watch"; default = 1080; }; + phasesBrightness = { + enable = lib.mkEnableOption "Set a specific brightness for the screen when running phases commands"; + backlight = lib.mkOption { type = lib.types.str; description = "Name of the backlight device"; }; + jour = lib.mkOption { type = lib.types.int; description = "brightness value for phase: jour"; }; + crepuscule = lib.mkOption { type = lib.types.int; description = "brightness value for phase: crepuscule"; }; + nuit = lib.mkOption { type = lib.types.int; description = "brightness value for phase: nuit"; }; + }; }; dev = { ansible = lib.mkEnableOption "Ansible dev stuff"; diff --git a/os/common.nix b/os/common.nix index 2195533..35c8d29 100644 --- a/os/common.nix +++ b/os/common.nix @@ -13,6 +13,7 @@ services.printing.enable = true; # Enable passwordless sudo + # TODO execWheelOnly? sudo-rs? security.sudo.extraRules = [{ groups = [ "wheel" ]; commands = [{ diff --git a/pindakaas/options.nix b/pindakaas/options.nix index b3b7910..8435783 100644 --- a/pindakaas/options.nix +++ b/pindakaas/options.nix @@ -5,6 +5,13 @@ xorg = true; x11_screens = [ "DP-1" "eDP-1" ]; maxVideoHeight = 720; + phasesBrightness = { + enable = true; + backlight = "edp-backlight"; + jour = 3500; + crepuscule = 3000; + nuit = 700; + }; }; frogeye.dev.docker = true; }