#!/bin/bash

# omarchy:summary=Reset the dock to the Omarchy default settings and pinned apps (backs up your shell.json).

set -euo pipefail

config_file="$HOME/.config/omarchy/shell.json"
backup_file="$config_file.bak.$(date +%s)"

# A second refresh within the same second leaves the first one's backup alone.
if [[ -f $config_file && ! -e $backup_file ]]; then
  cp -f "$config_file" "$backup_file"
fi

omarchy-dock defaults

if [[ -f $backup_file ]] && cmp -s "$config_file" "$backup_file"; then
  rm "$backup_file"
fi
