Remove notify-battery script with i3-battery-popup
https://github.com/rjekker/i3-battery-popup
This commit is contained in:
parent
5160384b10
commit
f982861233
|
@ -54,7 +54,6 @@ in
|
|||
build-glove80
|
||||
gscan2pdf
|
||||
meslo-lg
|
||||
notify-battery
|
||||
obs-studio
|
||||
okular
|
||||
pamixer
|
||||
|
|
|
@ -148,12 +148,6 @@
|
|||
|
||||
services.blueman.enable = true;
|
||||
|
||||
services.cron = {
|
||||
enable = true;
|
||||
|
||||
systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
|
||||
};
|
||||
|
||||
services.auto-cpufreq.enable = true;
|
||||
|
||||
services.udev = {
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
|
||||
blueman.enable = true;
|
||||
|
||||
cron = {
|
||||
enable = true;
|
||||
|
||||
systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
|
||||
};
|
||||
|
||||
gvfs.enable = true;
|
||||
openssh.enable = true;
|
||||
power-profiles-daemon.enable = false;
|
||||
|
|
|
@ -20,14 +20,6 @@ in
|
|||
|
||||
config = mkIf config.features.desktop.i3.enable {
|
||||
services = {
|
||||
cron = {
|
||||
enable = true;
|
||||
|
||||
systemCronJobs = [
|
||||
"* * * * * opdavies ${pkgs.notify-battery}/bin/notify-battery"
|
||||
];
|
||||
};
|
||||
|
||||
displayManager.defaultSession = "none+i3";
|
||||
|
||||
xserver = {
|
||||
|
@ -108,6 +100,7 @@ in
|
|||
|
||||
exec_always --no-startup-id caffeine
|
||||
exec_always --no-startup-id ${pkgs.autorandr}/bin/autorandr --change
|
||||
exec_always --no-startup-id ${pkgs.i3-battery-popup}/bin/i3-battery-popup -n
|
||||
|
||||
smart_borders on
|
||||
smart_gaps on
|
||||
|
|
|
@ -8,7 +8,7 @@ in
|
|||
{
|
||||
build-glove80 = callPackage ./build-glove80.nix { };
|
||||
notes = callPackage ./notes.nix { };
|
||||
notify-battery = callPackage ./notify-battery.nix { };
|
||||
i3-battery-popup = callPackage ./i3-battery-popup.nix { };
|
||||
tmux-sessionizer = callPackage ./tmux-sessionizer.nix { };
|
||||
|
||||
vimPlugins = prev.vimPlugins // vimPlugins;
|
||||
|
|
21
nix/pkgs/i3-battery-popup.nix
Normal file
21
nix/pkgs/i3-battery-popup.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "i3-battery-popop";
|
||||
version = "1.1.1";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "rjekker";
|
||||
repo = "i3-battery-popup";
|
||||
rev = "v${version}";
|
||||
sha256 = "s6jZCkB0Z8dtnBG2p1NJIUY1fV4urEp4w6wFzxFNlqg=";
|
||||
};
|
||||
|
||||
buildInputs = with pkgs; [ bash ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $src/i3-battery-popup $out/bin/i3-battery-popup
|
||||
chmod +x $out/bin/i3-battery-popup
|
||||
'';
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "notify-battery";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
acpi
|
||||
bash
|
||||
coreutils
|
||||
dbus
|
||||
];
|
||||
|
||||
text = ''
|
||||
set +o nounset
|
||||
set +o pipefail
|
||||
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
|
||||
export DISPLAY=:0
|
||||
|
||||
# Battery percentage at which to notify.
|
||||
BATTERY_DISCHARGING=$(acpi -b | grep "Battery 0" | grep -c "Discharging")
|
||||
BATTERY_LEVEL=$(acpi -b | grep "Battery 0" | grep -P -o '[0-9]+(?=%)')
|
||||
WARNING_LEVEL=20
|
||||
|
||||
# Use two files to store whether we've shown a notification or not (to prevent multiple notifications).
|
||||
EMPTY_FILE=/tmp/battery-empty
|
||||
FULL_FILE=/tmp/battery-full
|
||||
|
||||
# Reset notifications if the computer is charging/discharging.
|
||||
if [ "$BATTERY_DISCHARGING" -eq 1 ] && [ -f $FULL_FILE ]; then
|
||||
rm $FULL_FILE
|
||||
elif [ "$BATTERY_DISCHARGING" -eq 0 ] && [ -f $EMPTY_FILE ]; then
|
||||
rm $EMPTY_FILE
|
||||
fi
|
||||
|
||||
# If the battery is charging and is full (and has not shown notification yet).
|
||||
if [ "$BATTERY_LEVEL" -gt 95 ] && [ "$BATTERY_DISCHARGING" -eq 0 ] && [ ! -f $FULL_FILE ]; then
|
||||
notify-send "Battery Charged" "Battery is fully charged." -r 9991
|
||||
touch $FULL_FILE
|
||||
# If the battery is low and is not charging (and has not shown notification yet).
|
||||
elif [ "$BATTERY_LEVEL" -le $WARNING_LEVEL ] && [ "$BATTERY_DISCHARGING" -eq 1 ] && [ ! -f $EMPTY_FILE ]; then
|
||||
notify-send "Low Battery" "''${BATTERY_LEVEL}% of battery remaining." -u critical -r 9991 -t 0
|
||||
touch $EMPTY_FILE
|
||||
fi
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue