Remove the dead Thorium/Fitatu autostart instead of splitting it
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run

setup_thorium_startup.sh (443 lines) was queued for a split under the 250-line
cap. It turned out the feature it installs has been broken since Thorium was
removed in favour of chromium/librewolf.

/usr/local/bin/thorium-browser is now only a leftover symlink to
browser-preexec-wrapper, which routes by basename to /usr/bin/<name>. With no
/usr/bin/thorium-browser it falls into its testing branch and treats the URL as
the binary, so every boot logged:

  thorium-browser: line 33: /https://www.fitatu.com/app/planner: No such file

while systemd reported status=0/SUCCESS and "Finished". The success status is
why this went unnoticed.

Splitting a 443-line script to keep a dead feature under a line cap is the
wrong work, so it is deleted instead, along with its checker.

Removing check_thorium_startup() from check_and_enable_services.sh is the part
that makes this stick: its report_and_fix RE-RAN the installer whenever the
service was not enabled, so deleting only the deployed units would have let
them come back. Verified afterwards that the hourly maintenance timer runs a
deployed script with no thorium reference, and that nothing on a timer invokes
the checker at all.

Also removed from fresh-install/main.sh so new machines skip it. Units disabled
and all four deployed files removed. The generic browser-candidate lists that
merely mention thorium are left alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
This commit is contained in:
Krzysztof Rudnicki 2026-08-17 08:08:09 +02:00
parent 6066201e23
commit 5dce82f2c7
4 changed files with 64 additions and 481 deletions

View File

@ -0,0 +1,63 @@
{
"intent": "Remove the Thorium/Fitatu auto-startup feature entirely -- repo scripts, the self-healing checker that would recreate it, and the deployed units/files -- because Thorium was removed from this machine in favour of chromium/librewolf and the feature has been failing silently at every boot.",
"scope": [
"Deleted: linux_configuration/scripts/single_use/setup_thorium_startup.sh (443 lines)",
"linux_configuration/scripts/periodic_background/check_and_enable_services.sh (check_thorium_startup, its THORIUM_STARTUP_SCRIPT path, the dispatch call, and the summary-loop key)",
"linux_configuration/scripts/single_use/fresh-install/main.sh (the setup invocation on a new machine)",
"Live system: both systemd units disabled and removed, the launcher and autostart .desktop deleted",
"Non-goal: the generic browser-probe lists that mention thorium among many browsers (hosts/install.sh, lib/periodic_browser.sh, install_ublock.sh) -- those enumerate candidates and are harmless with thorium absent",
"Non-goal: /usr/local/bin/thorium-browser, the leftover symlink into browser-preexec-wrapper -- left in place, since removing it is a separate decision about the browser wrapper set"
],
"changes": [
"Deleted setup_thorium_startup.sh outright rather than splitting it under the 250-line cap, which was the original task for this file. Splitting a 443-line script to keep a dead feature compliant is the wrong work.",
"Removed check_thorium_startup() from check_and_enable_services.sh. This was load-bearing: report_and_fix would RE-RUN the installer whenever the service was not enabled, so deleting only the deployed artifacts would have let them be recreated.",
"Removed the invocation from fresh-install/main.sh so a new machine does not install the dead feature.",
"Disabled the system unit (the user unit was already disabled), removed /etc/systemd/system/thorium-fitatu-startup.service, ~/.config/systemd/user/thorium-fitatu-startup.service, ~/.config/autostart/thorium-fitatu.desktop and /usr/local/bin/thorium-fitatu-launcher.sh, then reloaded both daemons."
],
"verification": [
{
"command": "journalctl -u thorium-fitatu-startup.service -b",
"result": "pass",
"evidence": "Confirmed the feature was already broken before any change: 'thorium-browser: line 33: /https://www.fitatu.com/app/planner: No such file or directory' at the Aug 16 boot, while systemd reported Main PID exited status=0/SUCCESS and 'Finished'. The success status is why the failure never surfaced."
},
{
"command": "command -v thorium-browser; ls -la /usr/local/bin/thorium-browser",
"result": "pass",
"evidence": "Resolves only to a leftover symlink to browser-preexec-wrapper. That wrapper routes by basename to /usr/bin/<name>; /usr/bin/thorium-browser does not exist, so it falls into its testing branch and treats the URL as the binary -- which is exactly the error above."
},
{
"command": "grep -rn 'setup_thorium_startup|check_thorium_startup|THORIUM_STARTUP|thorium_startup|thorium-fitatu' linux_configuration/ --include='*.sh'",
"result": "pass",
"evidence": "No matches. Every reference to the removed script, checker, status key and unit name is gone; the surviving 'thorium' hits are generic browser-candidate lists."
},
{
"command": "sudo bash linux_configuration/scripts/periodic_background/check_and_enable_services.sh --status",
"result": "pass",
"evidence": "Runs clean, exit 0. The Thorium section no longer appears and the summary lists the remaining 11 services. Pre-existing unrelated issues (hosts, compulsive_blocker, workout_locker) are unchanged."
},
{
"command": "pre-commit run shellcheck --files <the two edited scripts>; bash -n on both",
"result": "pass",
"evidence": "Passed, no suppressions added."
},
{
"command": "systemctl list-unit-files | grep thorium-fitatu; ls of the four deployed paths",
"result": "pass",
"evidence": "No unit files remain in either the system or user scope, and all four files are gone after daemon-reload."
},
{
"command": "grep -c thorium /usr/local/bin/periodic-system-maintenance.sh; grep -rn check_and_enable_services /etc/systemd/system /usr/local/bin",
"result": "pass",
"evidence": "The hourly periodic-system-maintenance timer runs a DEPLOYED script with zero thorium references, and nothing on any timer invokes check_and_enable_services.sh -- it is manual-only. So no automation recreates the removed artifacts. This mattered: the checker's report_and_fix would otherwise have reinstalled them."
}
],
"risks": [
"The Fitatu planner no longer opens automatically at boot. That is the intended outcome, confirmed by the user; it has not actually opened since Thorium was removed anyway.",
"/usr/local/bin/thorium-browser remains as a dangling symlink into browser-preexec-wrapper. Anything invoking `thorium-browser` still fails the same way it did before this change. Left deliberately, as pruning the wrapper's symlink set is a separate decision.",
"check_and_enable_services.sh is 1337 lines and remains over the file-length cap; this change makes it ~33 lines shorter but does not address that."
],
"rollback": [
"git revert restores setup_thorium_startup.sh, the checker function and the fresh-install invocation. Re-running `sudo linux_configuration/scripts/single_use/setup_thorium_startup.sh` would then recreate every deployed artifact, since that script is the sole installer for them.",
"Note the restored feature would still be broken until a browser named thorium-browser exists at /usr/bin, so a rollback should be paired with retargeting the launcher at chromium."
]
}

View File

@ -42,7 +42,6 @@ HOSTS_INSTALL_SCRIPT="$CONFIG_DIR/scripts/periodic_background/hosts/install.sh"
HOSTS_GUARD_SCRIPT="$CONFIG_DIR/scripts/periodic_background/hosts/guard/setup_hosts_guard.sh"
HOSTS_PACMAN_HOOKS_SCRIPT="$CONFIG_DIR/scripts/periodic_background/hosts/guard/install_pacman_hooks.sh"
COMPULSIVE_BLOCK_SCRIPT="$CONFIG_DIR/scripts/periodic_background/digital_wellbeing/block_compulsive_opening.sh"
THORIUM_STARTUP_SCRIPT="$CONFIG_DIR/scripts/single_use/setup_thorium_startup.sh"
LEECHBLOCK_SCRIPT="$CONFIG_DIR/scripts/periodic_background/digital_wellbeing/install_leechblock.sh"
REMOVE_GUEST_MODE_SCRIPT="$CONFIG_DIR/scripts/periodic_background/digital_wellbeing/remove_guest_mode.sh"
VBOX_HOSTS_SCRIPT="$CONFIG_DIR/scripts/periodic_background/digital_wellbeing/virtualbox/enforce_vbox_hosts.sh"
@ -991,40 +990,6 @@ check_compulsive_blocker() {
SERVICE_STATUS["compulsive_blocker"]=$status
}
check_thorium_startup() {
header "Thorium Browser Auto-Startup (Fitatu)"
local status="ok"
local issues=()
# Check system service
if systemctl is-enabled thorium-fitatu-startup.service &>/dev/null; then
msg "thorium-fitatu-startup.service is enabled (system)"
else
# Check user service as fallback
local user="${SUDO_USER:-$USER}"
if user_systemctl "$user" is-enabled thorium-fitatu-startup.service &>/dev/null 2>&1; then
msg "thorium-fitatu-startup.service is enabled (user service)"
else
issues+=("thorium-fitatu-startup.service is not enabled")
status="error"
fi
fi
# Check if thorium is available
if command -v thorium-browser &>/dev/null || [[ -x /opt/thorium/thorium ]] || [[ -x /opt/thorium-browser/thorium-browser ]]; then
msg "Thorium browser is installed"
else
issues+=("Thorium browser not found")
if [[ $status != "error" ]]; then status="warning"; fi
fi
report_and_fix issues status "thorium_startup" \
"Setting up Thorium startup..." \
"$THORIUM_STARTUP_SCRIPT" \
"thorium-fitatu-startup.service"
}
check_leechblock() {
header "LeechBlock Browser Extension"
@ -1245,7 +1210,7 @@ print_summary() {
printf "%-25s %s\n" "Service" "Status"
printf "%-25s %s\n" "-------" "------"
for service in pacman_wrapper makepkg_wrapper midnight_shutdown startup_monitor periodic_systems hosts compulsive_blocker thorium_startup leechblock guest_mode_removal vbox_hosts workout_locker; do
for service in pacman_wrapper makepkg_wrapper midnight_shutdown startup_monitor periodic_systems hosts compulsive_blocker leechblock guest_mode_removal vbox_hosts workout_locker; do
local status="${SERVICE_STATUS[$service]:-unknown}"
local color
case "$status" in
@ -1303,7 +1268,6 @@ main() {
check_periodic_systems
check_hosts
check_compulsive_blocker
check_thorium_startup
check_leechblock
check_guest_mode_removal
check_vbox_hosts

View File

@ -297,7 +297,6 @@ scripts/fixes/nvidia_troubleshoot.sh
sudo scripts/features/setup_activitywatch.sh
sudo scripts/utils/setup_media_organizer.sh
yes | sudo scripts/periodic_background/setup_periodic_system.sh
sudo scripts/single_use/setup_thorium_startup.sh
yes | protonup
yes | sudo pacman -Syuu

View File

@ -1,443 +0,0 @@
#!/bin/bash
# Script to set up automatic Thorium browser launch with Fitatu website on startup
# Opens https://www.fitatu.com/ in Thorium browser every time the system boots
set -e # Exit on any error
# Source common library for shared functions
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
# shellcheck source=../lib/common.sh
source "$SCRIPT_DIR/../lib/common.sh"
# Initialize setup script (parse args, require root, print header)
init_setup_script "Thorium Browser Auto-Startup Setup" "$@"
# Target URL
TARGET_URL="https://www.fitatu.com/app/planner"
BROWSER_COMMAND="thorium-browser"
USER_HOME="/home/$(get_actual_user)"
echo ""
echo "Target URL: $TARGET_URL"
echo "Browser: $BROWSER_COMMAND"
echo "User home: $USER_HOME"
# Function to check if Thorium browser is installed
check_thorium_browser() {
echo ""
echo "1. Checking Thorium Browser Installation..."
echo "=========================================="
if ! command -v "$BROWSER_COMMAND" &>/dev/null; then
echo "Warning: Thorium browser not found in PATH"
echo "Checking alternative locations..."
# Check common installation paths
local alt_paths=(
"/opt/thorium/thorium"
"/usr/bin/thorium"
"/usr/local/bin/thorium"
"/opt/thorium-browser/thorium-browser"
"${USER_HOME}/.local/bin/thorium-browser"
)
local found=false
for path in "${alt_paths[@]}"; do
if [[ -x $path ]]; then
BROWSER_COMMAND="$path"
echo "✓ Found Thorium browser at: $path"
found=true
break
fi
done
if [[ $found != true ]]; then
echo "Error: Thorium browser not found!"
echo "Please install Thorium browser first or ensure it's in your PATH."
echo ""
echo "You can install Thorium browser from:"
echo "https://thorium.rocks/"
echo ""
local continue_anyway=false
if [[ $INTERACTIVE_MODE == "true" ]]; then
read -p "Continue anyway? The service will be created but may fail to start (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
continue_anyway=true
fi
else
echo "Auto-continuing anyway - service will be created but may fail to start (use --interactive to prompt)"
continue_anyway=true
fi
if [[ $continue_anyway != true ]]; then
exit 1
fi
fi
else
echo "✓ Thorium browser found: $(which $BROWSER_COMMAND)"
fi
}
# Function to create the browser launcher script
create_launcher_script() {
echo ""
echo "2. Creating Browser Launcher Script..."
echo "====================================="
local launcher_script="/usr/local/bin/thorium-fitatu-launcher.sh"
cat >"$launcher_script" <<EOF
#!/bin/bash
# Thorium browser launcher for Fitatu website
# Created by setup_thorium_startup.sh on $(date)
# Set up environment
export DISPLAY=:0
export HOME="$USER_HOME"
# Function to wait for X11 server and desktop environment
wait_for_desktop() {
local max_attempts=30
local attempt=0
echo "Waiting for X11 server and window manager to be ready..." >&2
# Wait for X11 server
while [[ \$attempt -lt \$max_attempts ]]; do
if xset q &>/dev/null 2>&1; then
echo "X11 server is ready" >&2
break
fi
sleep 1
((attempt++))
done
if [[ \$attempt -eq \$max_attempts ]]; then
echo "Timeout waiting for X11 server" >&2
return 1
fi
# Quick check for window manager (no waiting loop)
if pgrep -x i3 >/dev/null 2>&1; then
echo "i3 window manager detected and running" >&2
elif pgrep -x "i3wm" >/dev/null 2>&1; then
echo "i3wm window manager detected and running" >&2
elif wmctrl -m >/dev/null 2>&1; then
echo "Window manager detected via wmctrl" >&2
else
echo "Window manager not detected, proceeding anyway" >&2
fi
return 0
}
# Function to launch browser
launch_browser() {
echo "Launching Thorium browser with Fitatu..." >&2
# Try to launch browser as the original user
if command -v sudo &>/dev/null && [[ -n "${SUDO_USER}" ]]; then
sudo -u "${SUDO_USER}" env DISPLAY=:0 HOME="$USER_HOME" "$BROWSER_COMMAND" "$TARGET_URL" &
else
"$BROWSER_COMMAND" "$TARGET_URL" &
fi
local browser_pid=\$!
echo "Browser launched with PID: \$browser_pid" >&2
return 0
}
# Main execution
echo "\$(date): Starting Thorium-Fitatu launcher" >&2
if wait_for_desktop; then
launch_browser
echo "\$(date): Thorium browser launch completed" >&2
else
echo "\$(date): Failed to launch - desktop environment not ready" >&2
exit 1
fi
EOF
chmod +x "$launcher_script"
echo "✓ Created launcher script: $launcher_script"
}
# Function to create systemd service for user session
create_user_systemd_service() {
echo ""
echo "3. Creating User Systemd Service..."
echo "=================================="
local user_systemd_dir="$USER_HOME/.config/systemd/user"
local service_file="$user_systemd_dir/thorium-fitatu-startup.service"
# Create user systemd directory
sudo -u "${SUDO_USER}" mkdir -p "$user_systemd_dir"
# Create the service file
sudo -u "${SUDO_USER}" tee "$service_file" >/dev/null <<EOF
[Unit]
Description=Launch Thorium Browser with Fitatu on Startup
After=graphical-session.target
Wants=graphical-session.target
[Service]
Type=oneshot
Environment=DISPLAY=:0
Environment=HOME=$USER_HOME
ExecStart=/usr/local/bin/thorium-fitatu-launcher.sh
StandardOutput=journal
StandardError=journal
RemainAfterExit=yes
# Restart settings
Restart=no
# Timeout settings
TimeoutStartSec=120
[Install]
WantedBy=default.target
EOF
echo "✓ Created user systemd service: $service_file"
}
# Function to create system-wide systemd service (alternative approach)
create_system_systemd_service() {
echo ""
echo "4. Creating System Systemd Service..."
echo "===================================="
local service_file="/etc/systemd/system/thorium-fitatu-startup.service"
cat >"$service_file" <<EOF
[Unit]
Description=Launch Thorium Browser with Fitatu on Startup
After=multi-user.target network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=root
ExecStart=/usr/local/bin/thorium-fitatu-launcher.sh
StandardOutput=journal
StandardError=journal
RemainAfterExit=yes
# Environment
Environment=DISPLAY=:0
# Restart settings
Restart=no
# Timeout settings
TimeoutStartSec=180
[Install]
WantedBy=multi-user.target
EOF
echo "✓ Created system systemd service: $service_file"
}
# Function to create autostart desktop entry (additional method)
create_autostart_entry() {
echo ""
echo "5. Creating Autostart Desktop Entry..."
echo "====================================="
local autostart_dir="$USER_HOME/.config/autostart"
local desktop_file="$autostart_dir/thorium-fitatu.desktop"
# Create autostart directory
sudo -u "${SUDO_USER}" mkdir -p "$autostart_dir"
# Create desktop entry
sudo -u "${SUDO_USER}" tee "$desktop_file" >/dev/null <<EOF
[Desktop Entry]
Type=Application
Name=Thorium Fitatu Startup
Comment=Launch Thorium Browser with Fitatu website
Exec=/usr/local/bin/thorium-fitatu-launcher.sh
Icon=thorium-browser
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
StartupNotify=false
Terminal=false
Categories=Network;WebBrowser;
EOF
echo "✓ Created autostart desktop entry: $desktop_file"
}
# Function to create i3 config autostart entry
create_i3_autostart() {
echo ""
echo "6. Creating i3 Config Autostart Entry..."
echo "======================================="
local i3_config="$USER_HOME/.config/i3/config"
local i3_config_dir="$USER_HOME/.config/i3"
# Create i3 config directory if it doesn't exist
sudo -u "${SUDO_USER}" mkdir -p "$i3_config_dir"
# Check if i3 config exists
if [[ -f $i3_config ]]; then
# Check if autostart entry already exists
if ! sudo -u "${SUDO_USER}" grep -q "thorium-fitatu-launcher" "$i3_config"; then
# Add autostart entry to i3 config
sudo -u "${SUDO_USER}" bash -c "echo '' >> '$i3_config'"
sudo -u "${SUDO_USER}" bash -c "echo '# Auto-start Thorium browser with Fitatu' >> '$i3_config'"
sudo -u "${SUDO_USER}" bash -c "echo 'exec --no-startup-id /usr/local/bin/thorium-fitatu-launcher.sh' >> '$i3_config'"
echo "✓ Added autostart entry to i3 config: $i3_config"
else
echo "✓ Autostart entry already exists in i3 config"
fi
else
echo "Warning: i3 config file not found at $i3_config"
echo "You may need to manually add the following line to your i3 config:"
echo "exec --no-startup-id /usr/local/bin/thorium-fitatu-launcher.sh"
fi
}
# Function to create a script to enable user service after login
create_user_enable_script() {
local enable_script="$USER_HOME/.config/thorium-enable-service.sh"
sudo -u "${SUDO_USER}" tee "$enable_script" >/dev/null <<'EOF'
#!/bin/bash
# Script to enable thorium-fitatu-startup user service
# This runs once to enable the service, then removes itself
# Enable the user service
systemctl --user daemon-reload
systemctl --user enable thorium-fitatu-startup.service
# Remove this script after successful execution
rm "$0"
EOF
sudo -u "${SUDO_USER}" chmod +x "$enable_script"
# Add to user's .bashrc to run on next login
local bashrc="$USER_HOME/.bashrc"
if [[ -f $bashrc ]]; then
sudo -u "${SUDO_USER}" bash -c "echo '' >> '$bashrc'"
sudo -u "${SUDO_USER}" bash -c "echo '# Auto-enable thorium service (temporary)' >> '$bashrc'"
sudo -u "${SUDO_USER}" bash -c "echo '[[ -x ~/.config/thorium-enable-service.sh ]] && ~/.config/thorium-enable-service.sh' >> '$bashrc'"
fi
}
# Function to enable services
enable_services() {
echo ""
echo "7. Enabling Services..."
echo "======================"
# Reload systemd daemon
systemctl daemon-reload
echo "✓ System daemon reloaded"
# Enable system service
systemctl enable thorium-fitatu-startup.service
echo "✓ System service enabled"
# Enable lingering for the user (allows user services to run without login)
loginctl enable-linger "${SUDO_USER}"
echo "✓ User lingering enabled"
# Create a script to enable user service after login
create_user_enable_script
echo "✓ User service will be enabled on next login"
}
# Function to test the setup
test_setup() {
echo ""
echo "8. Testing Setup..."
echo "=================="
local run_test=true
if [[ $INTERACTIVE_MODE == "true" ]]; then
echo "Would you like to test the browser launcher now?"
read -p "Test launch Thorium browser with Fitatu? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
run_test=false
fi
else
echo "Auto-testing the browser launcher (use --interactive to prompt)"
fi
if [[ $run_test == "true" ]]; then
echo "Testing browser launch..."
echo "Note: This will open Thorium browser with Fitatu website"
# Test the launcher immediately
if /usr/local/bin/thorium-fitatu-launcher.sh; then
echo "✓ Test launch completed successfully"
else
echo "✗ Test launch failed"
echo "Check that Thorium browser is properly installed and accessible"
fi
else
echo "Skipping test launch"
fi
}
# Function to show usage instructions
show_instructions() {
echo ""
echo "=========================================="
echo "Thorium Browser Auto-Startup Setup Complete"
echo "=========================================="
echo "Summary:"
echo "✓ Launcher script created: /usr/local/bin/thorium-fitatu-launcher.sh"
echo "✓ System service created: thorium-fitatu-startup.service"
echo "✓ User service created: ~/.config/systemd/user/thorium-fitatu-startup.service"
echo "✓ Autostart entry created: ~/.config/autostart/thorium-fitatu.desktop"
echo "✓ i3 autostart entry added to: ~/.config/i3/config"
echo "✓ Services enabled for automatic startup"
echo ""
echo "The system will now:"
echo "• Launch Thorium browser with $TARGET_URL on every startup"
echo "• Use multiple methods to ensure reliable startup"
echo "• Wait for desktop environment to be ready before launching"
echo "• User service will be enabled automatically on next login"
echo ""
echo "To check status:"
echo " systemctl status thorium-fitatu-startup.service"
echo " systemctl --user status thorium-fitatu-startup.service (after login)"
echo ""
echo "To view logs:"
echo " journalctl -u thorium-fitatu-startup.service"
echo " journalctl --user -u thorium-fitatu-startup.service"
echo ""
echo "To disable (if needed):"
echo " sudo systemctl disable thorium-fitatu-startup.service"
echo " systemctl --user disable thorium-fitatu-startup.service"
echo " rm ~/.config/autostart/thorium-fitatu.desktop"
echo ""
echo "IMPORTANT: Browser will launch automatically on next reboot!"
}
# Main execution
check_thorium_browser
create_launcher_script
create_user_systemd_service
create_system_systemd_service
create_autostart_entry
create_i3_autostart
enable_services
test_setup
show_instructions