From f747d82b9336bb7c691d39a1f001c0d30d7bfb95 Mon Sep 17 00:00:00 2001 From: Davi Ribeiro <104164579+Markus328@users.noreply.github.com> Date: Sat, 23 Aug 2025 07:21:35 -0300 Subject: bar: add idle inhibitor (#459) * bar: add idle inhibitor * bar: change idle inhibitor button color * nix: link external scripts instead of install * services/idleinhibitor: add IPC handler * better styling * move cpp scripts to assets/cpp --------- Co-authored-by: Soramane <61896496+soramanew@users.noreply.github.com> --- nix/default.nix | 61 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'nix/default.nix') diff --git a/nix/default.nix b/nix/default.nix index e93f74b..6d0f3c8 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -30,6 +30,9 @@ quickshell, aubio, pipewire, + wayland, + wayland-protocols, + wayland-scanner, caelestia-cli, withCli ? false, extraRuntimeDeps ? [], @@ -61,15 +64,15 @@ fontconfig = makeFontsConf { fontDirectories = [material-symbols rubik nerd-fonts.caskaydia-cove]; }; -in - stdenv.mkDerivation { - pname = "caelestia-shell"; - version = "${rev}"; + + beatDetector = stdenv.mkDerivation { + pname = "beat-detector"; + version = "1.0"; + src = ./..; - nativeBuildInputs = [gcc makeWrapper qt6.wrapQtAppsHook]; - buildInputs = [quickshell aubio pipewire qt6.qtbase]; - propagatedBuildInputs = runtimeDeps; + nativeBuildInputs = [gcc]; + buildInputs = [aubio pipewire]; buildPhase = '' mkdir -p bin @@ -77,22 +80,62 @@ in -I${pipewire.dev}/include/pipewire-0.3 \ -I${pipewire.dev}/include/spa-0.2 \ -I${aubio}/include/aubio \ - assets/beat_detector.cpp \ + assets/cpp/beat-detector.cpp \ -o bin/beat_detector \ -lpipewire-0.3 -laubio ''; installPhase = '' install -Dm755 bin/beat_detector $out/bin/beat_detector + ''; + }; + + idleInhibitor = stdenv.mkDerivation { + pname = "wayland-idle-inhibitor"; + version = "1.0"; + + src = ./..; + + nativeBuildInputs = [gcc wayland-scanner wayland-protocols]; + buildInputs = [wayland]; + + buildPhase = '' + wayland-scanner client-header < ${wayland-protocols}/share/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml > idle-inhibitor.h + wayland-scanner private-code < ${wayland-protocols}/share/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml > idle-inhibitor.c + cp assets/cpp/idle-inhibitor.cpp . + gcc -o idle-inhibitor.o -c idle-inhibitor.c + g++ -o inhibit_idle idle-inhibitor.cpp idle-inhibitor.o -lwayland-client + ''; + + installPhase = '' + mkdir -p $out/bin + install -Dm755 inhibit_idle $out/bin/inhibit_idle + ''; + }; +in + stdenv.mkDerivation { + pname = "caelestia-shell"; + version = "${rev}"; + src = ./..; + + nativeBuildInputs = [gcc makeWrapper qt6.wrapQtAppsHook]; + buildInputs = [quickshell beatDetector idleInhibitor qt6.qtbase]; + propagatedBuildInputs = runtimeDeps; + + installPhase = '' mkdir -p $out/share/caelestia-shell cp -r ./* $out/share/caelestia-shell makeWrapper ${quickshell}/bin/qs $out/bin/caelestia-shell \ --prefix PATH : "${lib.makeBinPath runtimeDeps}" \ --set FONTCONFIG_FILE "${fontconfig}" \ - --set CAELESTIA_BD_PATH $out/bin/beat_detector \ + --set CAELESTIA_BD_PATH ${beatDetector}/bin/beat_detector \ + --set CAELESTIA_II_PATH ${idleInhibitor}/bin/inhibit_idle \ --add-flags "-p $out/share/caelestia-shell" + + ln -sf ${beatDetector}/bin/beat_detector $out/bin + ln -sf ${idleInhibitor}/bin/inhibit_idle $out/bin ''; meta = { -- cgit v1.2.3-freya