diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48a004c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist-newstyle diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6a1baec --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2023 Marty Sluijtman + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/app/Main.hs b/app/Main.hs index 7277ed5..01d6dc0 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,5 +1,10 @@ -batteryCapacityFile = "/sys/class/power_supply/BAT0/capacity" :: FilePath -batteryStatusFile = "/sys/class/power_supply/BAT0/status" :: FilePath +module Main where + +batteryCapacityFile :: String +batteryCapacityFile = "/sys/class/power_supply/BAT0/capacity" + +batteryStatusFile :: FilePath +batteryStatusFile = "/sys/class/power_supply/BAT0/status" main :: IO () main = do @@ -12,8 +17,8 @@ formatInfo status capacity = icon ++ " " ++ init capacity ++ "%" where icon | init status == "Full" = "🙂" | init status == "Charging" = "🔋" + | init status == "Discharging" = "🙃" | init status == "Not charging" = "â™ģ" | init status == "Unknown" = "Unknown" - | read capacity <= 20 = "đŸĒĢ" - | read capacity <= 100 = "🙃" + | (read capacity :: Int) <= 20 = "đŸĒĢ" | otherwise = "Silly" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0b19ca2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1691457739, + "narHash": "sha256-DqYeaBzTWypV0pTPsr5OMbsZc6Tqzv3SZkTUbeOEHaI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea34c2d97708e2618c48f8d5e1f24604c4e8db46", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..47a422b --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: 2021 Serokell +# +# SPDX-License-Identifier: CC0-1.0 + +{ + description = "My haskell application"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + haskellPackages = pkgs.haskellPackages; + + jailbreakUnbreak = pkg: + pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; })); + + packageName = "obtuse"; + in { + packages.${packageName} = + haskellPackages.callCabal2nix packageName self rec { + # Dependency overrides go here + }; + + packages.default = self.packages.${system}.${packageName}; + defaultPackage = self.packages.${system}.default; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + haskellPackages.haskell-language-server # you must build it with your ghc to work + ghcid + cabal-install + ]; + inputsFrom = map (__getAttr "env") (__attrValues self.packages.${system}); + }; + devShell = self.devShells.${system}.default; + }); +}