diff --git a/home-manager/home.nix b/home-manager/home.nix index 5a4a8d6..3a3fe22 100755 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,11 +1,17 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: # TODO: add OCR keybind on gnome - { nixpkgs.config.allowUnfree = true; home.packages = with pkgs; [ nixfmt-classic ]; + # my.enableHypr = lib.mkDefault true; + # options.my.enableHypr = lib.mkOption { + # type = lib.types.bool; + # default = true; + # description = "Enable Hyprland configuration."; + # }; + imports = [ ./modules/zsh/zsh.nix ./modules/kitty.nix @@ -15,7 +21,6 @@ ./modules/hypr/hypr.nix # TODO: make file with var for enable/disable hyprland ./modules/tmux.nix ]; - # programs.bash.bashrcExtra = ''echo "entering zsh" && zsh''; home.pointerCursor = let diff --git a/home-manager/modules/hypr/hypr.nix b/home-manager/modules/hypr/hypr.nix index ef45a99..85dc9cc 100644 --- a/home-manager/modules/hypr/hypr.nix +++ b/home-manager/modules/hypr/hypr.nix @@ -1,9 +1,9 @@ { config, pkgs, ... }: # TODO: -# - split into multiple files # - configure comands like hyprpaper, waybar, etc. # - make hyprexpo work +# - write config for hyprpanel { imports = [ @@ -13,7 +13,7 @@ # ./hyprland/rules.nix # ./hyprland/colors.nix # ./hyprland/active.nix - ./hyprland/keybinds.nix # in process + ./hyprland/keybinds.nix # done ./hyprlock.nix # done ./hypridle.nix # done ]; @@ -33,12 +33,12 @@ wayland.windowManager.hyprland = { enable = true; - # plugins = [ hyprexpo ]; + plugins = [ pkgs.hyprlandPlugins.hyprexpo ]; settings = { env = [ "XCURSOR_SIZE,24" "HYPRCURSOR_SIZE,24" ]; exec-once = [ - "hyprlock" + # "hyprlock" "hyprpanel &" "gsettings set org.gnome.desktop.interface cursor-theme '${config.home.pointerCursor.name}'" "gsettings set org.gnome.desktop.interface cursor-size ${ @@ -209,7 +209,7 @@ workspace_method = "first 1"; # [center/first] [workspace] e.g. first 1 or center m+1 - enable_gesture = false; # laptop touchpad, 4 fingers + enable_gesture = true; # laptop touchpad, 4 fingers gesture_distance = 300; # how far is the "max" gesture_positive = false; }; diff --git a/home-manager/modules/hypr/hyprland/keybinds.nix b/home-manager/modules/hypr/hyprland/keybinds.nix index f80bf13..e9c34a7 100644 --- a/home-manager/modules/hypr/hyprland/keybinds.nix +++ b/home-manager/modules/hypr/hyprland/keybinds.nix @@ -16,6 +16,7 @@ in { bind = [ "${super}, Super_L, exec, pkill fuzzel || fuzzel" + # "${super}, g, hyprexpo:expo, toggle" "${super}, H, exec, ~/.config/hypr/scripts/hide_window.sh h" "${super}, I, exec, ~/.config/hypr/scripts/hide_window.sh u" @@ -66,17 +67,17 @@ '' Ctrl+Shift, Escape, exec, ~/.config/hypr/scripts/launch_first_available.sh "kitty -1 fish -c btop"'' - "${super}+Alt, 1, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 1" - "${super}+Alt, 2, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 2" - "${super}+Alt, 3, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 3" - "${super}+Alt, 4, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 4" - "${super}+Alt, 5, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 5" - "${super}+Alt, 6, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 6" - "${super}+Alt, 7, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 7" - "${super}+Alt, 8, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 8" - "${super}+Alt, 9, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 9" - "${super}+Alt, 0, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 10" - "${super}+Alt, S, movetoworkspacesilent, special" + "${super}+Shift, 1, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 1" + "${super}+Shift, 2, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 2" + "${super}+Shift, 3, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 3" + "${super}+Shift, 4, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 4" + "${super}+Shift, 5, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 5" + "${super}+Shift, 6, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 6" + "${super}+Shift, 7, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 7" + "${super}+Shift, 8, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 8" + "${super}+Shift, 9, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 9" + "${super}+Shift, 0, exec, ~/.config/hypr/scripts/workspace_action.sh movetoworkspacesilent 10" + "${super}+Shift, S, movetoworkspacesilent, special" "${super}, S, togglespecialworkspace" ]; diff --git a/home-manager/modules/programs.nix b/home-manager/modules/programs.nix index a8bfe0d..b471186 100644 --- a/home-manager/modules/programs.nix +++ b/home-manager/modules/programs.nix @@ -11,6 +11,7 @@ lmstudio plantuml # amnezia-vpn + btop ]; # do i really need it? diff --git a/home-manager/modules/zsh/select_command.sh b/home-manager/modules/zsh/select_command.sh new file mode 100755 index 0000000..06a99f9 --- /dev/null +++ b/home-manager/modules/zsh/select_command.sh @@ -0,0 +1,171 @@ +SAVED_MODES_FILE=".saved_modes" +TEMP_FILE=".saved_modes.tmp" + +# Function to display the menu +show_menu() { + printf "\n\n=== Saved Modes ===\n" + + if [[ ! -f "$SAVED_MODES_FILE" ]] || [[ ! -s "$SAVED_MODES_FILE" ]]; then + echo "No saved modes found." + echo "" + return + fi + + local count=1 + while IFS= read -r line; do + if [[ -n "$line" ]]; then + local name=$(echo "$line" | cut -d' ' -f1) + local command=$(echo "$line" | cut -d' ' -f2-) + + # Truncate command to 40 characters max + if [[ ${#command} -gt 40 ]]; then + command="${command:0:40}..." + fi + + printf "%2d) %-15s %s\n" "$count" "$name" "$command" + ((count++)) + fi + done < "$SAVED_MODES_FILE" + echo "" +} + +# Function to add a new mode +add_mode() { + echo "Adding new mode:" + read -p "Enter name: " new_name + read -p "Enter command: " new_command + + if [[ -n "$new_name" && -n "$new_command" ]]; then + # Create temp file with new entry at the beginning + echo "$new_name $new_command" > "$TEMP_FILE" + if [[ -f "$SAVED_MODES_FILE" ]]; then + cat "$SAVED_MODES_FILE" >> "$TEMP_FILE" + fi + mv "$TEMP_FILE" "$SAVED_MODES_FILE" + echo "Mode '$new_name' added successfully!" + else + echo "Error: Name and command cannot be empty." + fi + echo "" +} + +# Function to remove a mode +remove_mode() { + local mode_num=$1 + local count=0 + + if [[ ! -f "$SAVED_MODES_FILE" ]]; then + echo "No saved modes file found." + return + fi + + # Count total lines + total_lines=$(wc -l < "$SAVED_MODES_FILE") + + if [[ $mode_num -lt 1 || $mode_num -gt $total_lines ]]; then + echo "Error: Invalid mode number $mode_num" + return + fi + + # Create temp file without the specified line + rm -f "$TEMP_FILE" + touch "$TEMP_FILE" + local current_line=1 + while IFS= read -r line; do + if [[ $current_line -ne $mode_num ]]; then + echo "$line" >> "$TEMP_FILE" + else + echo "Removed mode: $line" + fi + ((current_line++)) + done < "$SAVED_MODES_FILE" + + mv "$TEMP_FILE" "$SAVED_MODES_FILE" + echo "Mode $mode_num removed successfully!" + echo "" +} + +# Function to execute a mode +execute_mode() { + local mode_num=$1 + + if [[ ! -f "$SAVED_MODES_FILE" ]]; then + echo "Error: No saved modes file found." + return 1 + fi + + # Get the command for the specified mode number + local command_line=$(sed -n "${mode_num}p" "$SAVED_MODES_FILE") + local command=$(echo "$command_line" | cut -d' ' -f2-) + + if [[ -z "$command" ]]; then + echo "Error: Could not find command for mode $mode_num" + return 1 + fi + + # Clear terminal and execute command + #clear + echo "Executing: $command" + echo "========================================" + eval "$command" + exit 0 +} + +# Main script loop +main() { + while true; do + show_menu + + echo "Options:" + echo " [number] - Execute mode" + echo " n - Add new mode" + echo " r[number] - Remove mode (e.g., r1)" + echo " e - Exit" + echo "" + + read -p "Enter choice: " input + + case "$input" in + [eE]) + echo "Goodbye!" + exit 0 + ;; + [nN]) + add_mode + ;; + r[0-9]*) + # Extract number after 'r' + local mode_num="${input#r}" + if [[ "$mode_num" =~ ^[0-9]+$ ]]; then + remove_mode "$mode_num" + else + echo "Error: Invalid format. Use r1, r2, etc." + echo "" + fi + ;; + [0-9]*) + if [[ "$input" =~ ^[0-9]+$ ]]; then + execute_mode "$input" + else + echo "Error: Please enter a valid number" + echo "" + fi + ;; + *) + echo "Error: Invalid input. Please try again." + echo "" + ;; + esac + done +} + +# Cleanup function +cleanup() { + rm -f "$TEMP_FILE" +} + +# Set up cleanup on exit +trap cleanup EXIT + +# Run main function +main diff --git a/home-manager/modules/zsh/zsh.nix b/home-manager/modules/zsh/zsh.nix index 7a0325f..b169ee3 100644 --- a/home-manager/modules/zsh/zsh.nix +++ b/home-manager/modules/zsh/zsh.nix @@ -1,7 +1,17 @@ { config, pkgs, ... }: { - home.packages = with pkgs; [ zsh-powerlevel10k fzf fd eza zoxide ]; + home.packages = with pkgs; [ + (writeShellScriptBin "select_command" + (builtins.readFile ./select_command.sh)) + zsh-powerlevel10k + fzf + fd + eza + zoxide + ]; + + home.file.".p10k.zsh".source = ./p10k.zsh; programs.zsh = { enable = true; @@ -70,7 +80,7 @@ AmneziaVPN > /dev/null 2>&1 & ''; # TODO: start system with service cnfg = "cd nixos-config && code . && exit"; - + x = "select_command"; }; initContent = '' @@ -113,6 +123,4 @@ ''; }; - home.file.".p10k.zsh".source = ./p10k.zsh; - } diff --git a/remove-all-bckps.sh b/remove-all-bckps.sh index a96340c..177e223 100755 --- a/remove-all-bckps.sh +++ b/remove-all-bckps.sh @@ -13,6 +13,6 @@ echo "Removing all backups in $HOME/.config/home-manager..." rm -rf $HOME/.config/home-manager.bak.* echo "Run nix-collect-garbage" -nix-collect-garbage +nix-collect-garbage --delete-older-than 7d echo "Done!" \ No newline at end of file