about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/xbattbar
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-01-10 07:13:44 +0000
committerAlyssa Ross <hi@alyssa.is>2021-01-12 14:07:16 +0000
commite2698550456abba83c6dcd5d5e5a9990a0b96f8a (patch)
tree79a56f0df3fa55e470d84b4dff6059fbf487ec18 /nixpkgs/pkgs/applications/misc/xbattbar
parent1cdc42df888dc98c347e03bd942ed9825a55bcb3 (diff)
parent84d74ae9c9cbed73274b8e4e00be14688ffc93fe (diff)
downloadnixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar.gz
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar.bz2
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar.lz
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar.xz
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.tar.zst
nixlib-e2698550456abba83c6dcd5d5e5a9990a0b96f8a.zip
Merge commit '84d74ae9c9cbed73274b8e4e00be14688ffc93fe'
Diffstat (limited to 'nixpkgs/pkgs/applications/misc/xbattbar')
-rw-r--r--nixpkgs/pkgs/applications/misc/xbattbar/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/misc/xbattbar/sys-by-default.patch26
2 files changed, 72 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/misc/xbattbar/default.nix b/nixpkgs/pkgs/applications/misc/xbattbar/default.nix
new file mode 100644
index 000000000000..0864e24f8c9d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/misc/xbattbar/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchgit, libX11, perl, ... }:
+
+stdenv.mkDerivation rec {
+  pname = "xbattbar";
+  version = "1.4.9";
+
+  # The current active upstream of xbattbar seems to be the Debian source
+  # repository.
+  src = fetchgit {
+    url = "https://salsa.debian.org/debian/xbattbar.git";
+    rev = "upstream/${version}";
+    sha256 = "10w7gs0l4hzhdn38yqyr3az7n4ncmfnd6hhhly6lk5dg7k441ck6";
+  };
+
+  buildInputs =  [ libX11 ];
+
+  # The following patches are applied:
+  # - sys-by-default: remove the APM checker binary, make the sys checker
+  #   script the default. Rationale: checking battery status by /proc/apm is
+  #   extremely oldschool and does not work on NixOS, while the sysfs script
+  #   does.
+  # - perl shebang patches for acpi/sys scripts
+  # - unhardcode path to checker scripts
+  patchPhase = ''
+    patch -p1 < ${./sys-by-default.patch}
+    sed -i -e "s,/usr/lib/xbattbar/,$out/libexec/," xbattbar.c
+    sed -i -e "s,/usr/bin/perl,${perl}/bin/perl," xbattbar-check-acpi
+    sed -i -e "s,/usr/bin/perl,${perl}/bin/perl," xbattbar-check-sys
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/libexec
+    install -m 0755 xbattbar $out/bin/
+    install -m 0755 xbattbar-check-acpi $out/libexec/
+    install -m 0755 xbattbar-check-sys $out/libexec/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Display battery status in X11";
+    homepage = "https://salsa.debian.org/debian/xbattbar";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.q3k ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/misc/xbattbar/sys-by-default.patch b/nixpkgs/pkgs/applications/misc/xbattbar/sys-by-default.patch
new file mode 100644
index 000000000000..367f7217eecb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/misc/xbattbar/sys-by-default.patch
@@ -0,0 +1,26 @@
+diff --git a/xbattbar.c b/xbattbar.c
+index 1e26019..cb3eab5 100644
+--- a/xbattbar.c
++++ b/xbattbar.c
+@@ -75,9 +75,8 @@ char *ONOUT_C  = "olive drab";
+ char *OFFIN_C  = "blue";
+ char *OFFOUT_C = "red";
+ 
+-char *EXTERNAL_CHECK = "/usr/lib/xbattbar/xbattbar-check-apm";
++char *EXTERNAL_CHECK = "/usr/lib/xbattbar/xbattbar-check-sys";
+ char *EXTERNAL_CHECK_ACPI = "/usr/lib/xbattbar/xbattbar-check-acpi";
+-char *EXTERNAL_CHECK_SYS = "/usr/lib/xbattbar/xbattbar-check-sys";
+ 
+ int alwaysontop = False;
+ 
+@@ -245,10 +244,6 @@ main(int argc, char **argv)
+       EXTERNAL_CHECK = EXTERNAL_CHECK_ACPI;
+       break;
+ 
+-    case 'r':
+-      EXTERNAL_CHECK = EXTERNAL_CHECK_SYS;
+-      break;
+-
+     case 's':
+       EXTERNAL_CHECK = optarg;
+       break;