@@ -16,6 +16,14 @@ source "${CORE_DIR}/logging.sh"
1616source " ${CORE_DIR} /state.sh"
1717source " ${CORE_DIR} /self_update.sh"
1818
19+ # Source Modules for direct access (Auto-Clean)
20+ source " ${MODULES_DIR} /cleanup/apt.sh"
21+ source " ${MODULES_DIR} /cleanup/docker.sh"
22+ source " ${MODULES_DIR} /cleanup/logs.sh"
23+ source " ${MODULES_DIR} /cleanup/ide.sh"
24+ source " ${MODULES_DIR} /cleanup/dev.sh"
25+ source " ${MODULES_DIR} /cleanup/system.sh"
26+
1927# ---------------- MAIN ----------------
2028main () {
2129 # Argument Parsing
@@ -89,61 +97,86 @@ main() {
8997 # Capture Start Storage
9098 START_SPACE=$( get_free_space)
9199
100+ # Main Loop State
101+ ACTIVE_TAB=" cleanup"
102+
92103 # Main Loop
104+ ACTIVE_TAB=" cleanup"
105+
93106 while true ; do
94- draw_header
107+ clear
95108
96- # storage info
109+ # storage info logic
97110 CURRENT_SPACE=$( get_free_space)
98111 FREED=$(( CURRENT_SPACE - START_SPACE ))
99- if (( FREED < 0 )) ; then FREED=0; fi # Just in case
100-
112+ if (( FREED < 0 )) ; then FREED=0; fi
113+ local freed_text= " "
101114 if (( FREED > 0 )) ; then
102- FREED_HR=$( human_readable_size " $FREED " )
103- gum style --foreground 212 " Session Reclaimed: $FREED_HR "
115+ freed_text=" Reclaimed: $( human_readable_size " $FREED " ) "
104116 fi
105-
106- # Main Menu Selection
107- # Single selection for navigation (Enter to select)
108- SELECTION=$( gum choose --cursor=" → " --header=" Select Maintenance Category (Enter to select)" \
117+
118+ # Prepare Header content
119+ HEADER=$( draw_header " $ACTIVE_TAB " )
120+
121+ # Sub-header / Status / Freed Space
122+ STATUS_BAR=$( gum style --foreground 240 --width $( tput cols) --align center " $freed_text " )
123+ FULL_HEADER=$( gum join --vertical " $HEADER " " $STATUS_BAR " )
124+
125+ # Menu Options based on Active Tab
126+ # To simulate tabs, the menu items change based on the active tab context.
127+ # But user can also switch tabs.
128+
129+ # Navigation Items (Always present)
130+ local nav_items=(" > System Cleanup" " > System Updates" " > Maintenance" " > View Logs" " > Exit" )
131+
132+ # We need a unified list.
133+ # Strategy: The "Tab" is just visual context. The Menu is the controller.
134+
135+ echo " $FULL_HEADER "
136+
137+ # Use gum choose for everything
138+ ACTION=$( gum choose --cursor=" » " --height=15 \
109139 " System Cleanup" \
110140 " System Updates" \
111141 " Maintenance" \
112- " Gaming Tweaks " \
142+ " Start Auto-Clean (All) " \
113143 " View Logs" \
114144 " Exit" )
115145
116- # Handle Empty Selection (User just hit Enter without selecting)
117- if [[ -z " $SELECTION " ]]; then
118- continue
119- fi
120-
121- # Process Selection
122- # Note: gum choose returns newline separated list of selected items
123- while IFS= read -r item; do
124- case " $item " in
125- " System Cleanup" ) run_module_menu " cleanup" ;;
126- " System Updates" ) run_module_menu " updates" ;;
127- " Maintenance" ) run_module_menu " maintenance" ;;
128- " Gaming Tweaks" ) run_module_menu " gaming" ;;
129- " View Logs" ) view_logs ;;
130- " Exit" )
131- END_SPACE=$( get_free_space)
132- DIFF=$(( END_SPACE - START_SPACE ))
133- if (( DIFF > 0 )) ; then
134- DIFF_HR=$( human_readable_size " $DIFF " )
135- clear
136- gum style --border double --margin 1 --padding 1 --foreground 212 " Bleach Finished!" " You reclaimed $DIFF_HR of disk space."
137- else
138- clear
139- gum style --border normal --margin 1 --padding 1 " Bleach Finished."
140- fi
141- exit 0
142- ;;
143- esac
144- done <<< " $SELECTION"
145-
146- # Pause before return happens inside modules usually, but loop restart clears screen
146+ case " $ACTION " in
147+ " System Cleanup" )
148+ ACTIVE_TAB=" cleanup"
149+ run_module_menu " cleanup"
150+ ;;
151+ " System Updates" )
152+ ACTIVE_TAB=" updates"
153+ run_module_menu " updates"
154+ ;;
155+ " Maintenance" )
156+ ACTIVE_TAB=" maintenance"
157+ run_module_menu " maintenance"
158+ ;;
159+ " Start Auto-Clean (All)" )
160+ # Just an example of "all things"
161+ ACTIVE_TAB=" cleanup"
162+ cleanup_system_logs
163+ cleanup_temp
164+ ;;
165+ " View Logs" )
166+ ACTIVE_TAB=" info"
167+ view_logs
168+ ;;
169+ " Exit" )
170+ END_SPACE=$( get_free_space)
171+ DIFF=$(( END_SPACE - START_SPACE ))
172+ if (( DIFF > 0 )) ; then
173+ gum style --border double --margin 1 --padding 1 --foreground 212 " Bleach Finished!" " You reclaimed $( human_readable_size " $DIFF " ) ."
174+ else
175+ gum style --border normal --margin 1 --padding 1 " Bleach Finished."
176+ fi
177+ exit 0
178+ ;;
179+ esac
147180 done
148181}
149182
0 commit comments