Rearrange folder struct
This commit is contained in:
66
home/scripts/startup/default.nix
Normal file
66
home/scripts/startup/default.nix
Normal file
@@ -0,0 +1,66 @@
|
||||
# File runned at startup by Hyprland
|
||||
{ pkgs, config, ... }:
|
||||
let
|
||||
homedir = config.home.homeDirectory;
|
||||
variable = import ../../../variables.nix;
|
||||
|
||||
battery-notif = pkgs.writeShellScriptBin "battery-notif" ''
|
||||
# Send notifications when low on battery and not in charge
|
||||
while true; do
|
||||
battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
|
||||
battery_status=$(cat /sys/class/power_supply/BAT*/status)
|
||||
if [[ $battery_level -le 20 ]] && [[ $battery_status == "Discharging" ]]; then
|
||||
${pkgs.libnotify}/bin/notify-send " Low battery" "Battery level is $battery_level%"
|
||||
elif [[ $battery_level -le 10 ]] && [[ $battery_status == "Discharging" ]]; then
|
||||
${pkgs.libnotify}/bin/notify-send --urgency=critical " Very low battery" "Battery level is $battery_level%"
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
'';
|
||||
|
||||
nextcloud-watch = pkgs.writeShellScriptBin "nextcloud-watch" ''
|
||||
# Start nextcloud if I'm on my networks
|
||||
while true;do
|
||||
ssid=$(nmcli -t -f name connection show --active | head -n1)
|
||||
status=$(pgrep -n nextcloud)
|
||||
if [[ -z $status ]]; then
|
||||
service_status="inactive"
|
||||
else
|
||||
service_status="active"
|
||||
fi
|
||||
|
||||
if [[ $ssid == "inthecloud" || $ssid == "Wired connection 2" ]]; then
|
||||
if [[ $service_status == "inactive" ]]; then
|
||||
${pkgs.nextcloud-client}/bin/nextcloud --background
|
||||
fi
|
||||
else
|
||||
if [[ $service_status == "active" ]]; then
|
||||
pkill nextcloud
|
||||
fi
|
||||
fi
|
||||
sleep 120
|
||||
done
|
||||
'';
|
||||
|
||||
startup = pkgs.writeShellScriptBin "startup" ''
|
||||
# Because HM enabling services suck.
|
||||
|
||||
[[ ${
|
||||
toString variable.enableSops
|
||||
} == "true" ]] && systemctl --user start sops-nix
|
||||
|
||||
[[ ${toString variable.enableNextcloud} == "true" ]] && nextcloud-watch &
|
||||
|
||||
battery-notif &
|
||||
sleep 2
|
||||
${pkgs.waybar}/bin/waybar &
|
||||
'';
|
||||
|
||||
in {
|
||||
home.packages = with pkgs; [
|
||||
startup
|
||||
battery-notif
|
||||
nextcloud-watch
|
||||
nextcloud-client
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user