From 4feb5b89e8e803c2d5308300656f16836f122e65 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Wed, 1 Oct 2025 13:38:54 -0400 Subject: [PATCH] wip: got inhibit working but fish_greeting fails --- home/shell.nix | 198 +++++++++++++++++++++++++++++-------------------- 1 file changed, 119 insertions(+), 79 deletions(-) diff --git a/home/shell.nix b/home/shell.nix index 9941b9f..d4e30a0 100644 --- a/home/shell.nix +++ b/home/shell.nix @@ -1,85 +1,125 @@ -{pkgs, ...}: { - programs.fish = { - enable = true; - # initExtra = '' - # export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" - # ''; - - shellAliases = { - # ls aliases - ls = "eza --color"; - la = "eza -l -all --color"; - ll = "eza -l --color"; - lt = "eza -l --color --git"; - - # lazygit alias - lg = "lazygit"; - - # cat, less, more alias - cat = "bat"; - less = "bat"; - more = "bat"; - - # top alias - top = "btm"; - }; - - functions = { - fish_greeting = { - body = '' - set memes \ - "Crazy? I was crazy once. They locked me in a room. A rubber room. A rubber room with rats. And rats make me crazy." \ - "Daddy, chill!" \ - "What the hell is even that?!" \ - "Road work ahead? Yeah, I sure hope it does!" \ - "Look at all those chickens!" \ - "I smell like beef" \ - "Say, Coloardo - I'M A GIRAFFE" \ - "I didn't get no sleep cause of y'all, y'all not gone get any sleep cause of me!" \ - "This is the dollar store, how good can it be?" \ - "That was legitness" \ - "Deez nuts" \ - "I wanna be a cowboy baby" \ - "Can I get a waffle? Can I please get a waffle?" \ - "I'm lesbian. I thought you were American." \ - "You gotta give 'em that 'hawk tuah' and spit on that thang!" \ - "We don't do that here..." - - set choose_meme (random)"%"(count $memes) - set choose_meme $memes[(math $choose_meme"+1")] - - printf (set_color F90)"%s\n" $choose_meme - ''; - onEvent = "fish_greeting"; +{ + lib, + pkgs, + userName, + ... +}: { + programs = { + fish = { + enable = true; + shellAliases = { + # ls aliases + ls = "eza --color"; + la = "eza -l -all --color"; + ll = "eza -l --color"; + lt = "eza -l --color --git"; + # lazygit alias + lg = "lazygit"; + # cat, less, more alias + cat = "bat"; + less = "bat"; + more = "bat"; + # top alias + top = "btm"; }; + functions = + { + fish_greeting = { + body = '' + set memes \ + "Crazy? I was crazy once. They locked me in a room. A rubber room. A rubber room with rats. And rats make me crazy." \ + "Daddy, chill!" \ + "What the hell is even that?!" \ + "Road work ahead? Yeah, I sure hope it does!" \ + "Look at all those chickens!" \ + "I smell like beef" \ + "Say, Coloardo - I'M A GIRAFFE" \ + "I didn't get no sleep cause of y'all, y'all not gone get any sleep cause of me!" \ + "This is the dollar store, how good can it be?" \ + "That was legitness" \ + "Deez nuts" \ + "I wanna be a cowboy baby" \ + "Can I get a waffle? Can I please get a waffle?" \ + "I'm lesbian. I thought you were American." \ + "You gotta give 'em that 'hawk tuah' and spit on that thang!" \ + "We don't do that here..." \ + "What are those?! They are my crocs..." \ + "It's an avocado... Thanks!" \ + "I am once again asking for your financial support" \ + "Is that a weed?" \ + "No, this is Patrick!" \ + "Come ride, heroes, ride" \ + "Away with the tide" \ + "Concede your mind unto the fiend" \ + "Darkness come, rend the shield of light" \ + "The sun is setting, darkness taking over - a date with chaos and you're dressed to the nines" \ + "Now kneel overdweller, your lord commands, there's no salvation for the sons of man" \ + "Snap click clank whirr whizz wham boom!" \ + "Rohs an kyn ala na" + + set choose_meme (random)"%"(count $memes) + set choose_meme $memes[(math $choose_meme"+1")] + printf (set_color F90)"%s\n" $choose_meme + ''; + # onEvent = "fish_greeting"; + }; + } // (lib.mkIf pkgs.stdenv.isLinux { + block = { + body = '' + echo "Starting systemd-inhibit..." + set inhibit_pid_file /tmp/fish_inhibit_pid_(whoami) + bash -c 'systemd-inhibit --no-ask-password --what=idle --who="'${userName}'" --why="manual invocation" sh & echo $! > '"$inhibit_pid_file"' && disown' + if test -f $inhibit_pid_file + set -g INHIBIT_PID (cat $inhibit_pid_file) + echo "Inhibit process started with PID: $INHIBIT_PID" + else + echo "Failed to start inhibit process" + return 1 + end + ''; + }; + unblock = { + body = '' + set inhibit_pid_file /tmp/fish_inhibit_pid_(whoami) + if test -f $inhibit_pid_file + set INHIBIT_PID (cat $inhibit_pid_file) + echo "Killing inhibit process: $INHIBIT_PID" + kill -SIGTERM $INHIBIT_PID 2>/dev/null; or kill -SIGKILL $INHIBIT_PID 2>/dev/null + rm -f $inhibit_pid_file + set -e INHIBIT_PID + echo "Inhibit process terminated" + else + echo "No inhibit process file found" + end + ''; + }; + }); }; - }; - - programs.zsh = { - enable = true; - initContent = '' - if [[ -z "$BASH_EXECUTION_STRING" ]]; then - if [[ -n "$ZSH_VERSION" ]]; then - LOGIN_OPTION="--login" - else - LOGIN_OPTION="" + zsh = { + enable = true; + initContent = '' + if [[ -z "$BASH_EXECUTION_STRING" ]]; then + if [[ -n "$ZSH_VERSION" ]]; then + LOGIN_OPTION="--login" + else + LOGIN_OPTION="" + fi + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION fi - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION - fi - ''; - }; - - programs.bash = { - enable = true; - initExtra = '' - if [[ -z "$BASH_EXECUTION_STRING" ]]; then - if [[ -n "$ZSH_VERSION" ]]; then - LOGIN_OPTION="--login" - else - LOGIN_OPTION="" + ''; + }; + bash = { + enable = true; + initExtra = '' + if [[ -z "$BASH_EXECUTION_STRING" ]]; then + if [[ -n "$ZSH_VERSION" ]]; then + LOGIN_OPTION="--login" + else + LOGIN_OPTION="" + fi + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION fi - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION - fi - ''; + ''; + }; }; }