diff --git a/README.md b/README.md index 9737fa8..a304d63 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ It runs these steps, in this order, and every one of them is idempotent: | 1. Directories | creates the 19 directories the shell and scripts expect, before anything writes into them | | 2. `BLOB_PATH` | symlinks `~/.local/share/blob` to this checkout | | 3. Packages | installs what is missing from `packages/`, bootstrapping `yay` first on a machine that has no AUR helper | -| 4. Config | copies `hypr/`, the themed app configs, `blob/shell.json`, and the uwsm environment into `~/.config`, and writes `/etc/profile.d/blob.sh` so a login shell finds the `blob` command | +| 4. Config | copies `hypr/`, the themed app configs, `blob/shell.json`, and the uwsm environment into `~/.config`, sets the default apps for images, video, PDFs and office files, and writes `/etc/profile.d/blob.sh` so a login shell finds the `blob` command | | 5. First theme | links `~/wallpapers` to the checkout, applies `flats` headless, picks a background, and links the btop and Neovim theme files, so the first login is not a blank desktop | | 6. User units | installs the session services into `~/.config/systemd/user` and enables them | | 7. systemd drop-ins | writes the shutdown timeouts, oomd thresholds, plocate prune paths, and sleep hooks under `/etc` | diff --git a/docs/install.md b/docs/install.md index a062953..d16e041 100644 --- a/docs/install.md +++ b/docs/install.md @@ -17,6 +17,7 @@ with `--check`. | `install/steps/services.sh` | system services, systemd drop-ins, user units | | `install/steps/boot.sh` | the Plymouth boot splash, GRUB, and other-OS detection | | `install/steps/theme.sh` | the wallpaper link, the first theme, the first background | +| `install/steps/apps.sh` | default applications for images, video, PDFs and office files | | `install/steps/login.sh` | SDDM, the session entry, and the first launch | | `install/steps/reload.sh` | reloading systemd, the user services, and a running session | @@ -45,6 +46,10 @@ with `--check`. panels come up full of blanks. `fonts.conf` binds `monospace` to `JetBrainsMono Nerd Font`; `blob font set` rewrites the same file, and the installer then reports it as a local change and keeps your choice. + Default applications are set in `~/.config/mimeapps.list`: `imv` for + images, `mpv` for video and audio, `evince` for PDFs, and LibreOffice for + documents, spreadsheets and presentations. A file type that already has a + default there is left alone. See [packages.md](packages.md#desktop-applications). `~/.bashrc` gets one line sourcing `session/bashrc`. The line is added once, a `.bak` is kept, and a `~/.bashrc` that already has it is left alone. `session/profile.sh` also goes to `/etc/profile.d/blob.sh`, which sources diff --git a/docs/packages.md b/docs/packages.md index 8456c4a..7a2cb9a 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -136,6 +136,23 @@ Omarchy's own package list, because they were installed by hand on this machine: `playerctl` is in official `extra`, so it sits in the repo list. +## Desktop applications + +The everyday apps come from the official repositories with everything else: + +| Package | Opens | +| --- | --- | +| `imv` | images | +| `mpv` | video and audio | +| `evince` | PDFs | +| `libreoffice-fresh` | documents, spreadsheets and presentations (Writer, Calc, Impress) | +| `kdenlive` | video editing | + +`install.sh` makes them the default for their file types through `xdg-mime`, +which writes `~/.config/mimeapps.list`. A type that already has a default in +that file is left alone, so a choice you made yourself always wins, and an app +that is not installed is skipped. + ## The boot splash `install.sh` sets the splash to `branding/blob_boot.png`. To change it later: diff --git a/install.sh b/install.sh index f86e283..d360d47 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,7 @@ source "$repo_dir/install/steps/config.sh" source "$repo_dir/install/steps/services.sh" source "$repo_dir/install/steps/boot.sh" source "$repo_dir/install/steps/theme.sh" +source "$repo_dir/install/steps/apps.sh" source "$repo_dir/install/steps/login.sh" source "$repo_dir/install/steps/reload.sh" @@ -73,6 +74,7 @@ install_bash_integration install_user_units install_systemd_dropins install_zen_config +install_default_apps link_wallpapers install_default_theme diff --git a/install/steps/apps.sh b/install/steps/apps.sh new file mode 100644 index 0000000..a0e31be --- /dev/null +++ b/install/steps/apps.sh @@ -0,0 +1,53 @@ +mimeapps_file="$config_dir/mimeapps.list" + +default_app_associations=( + "imv.desktop:image/png image/jpeg image/gif image/webp image/bmp image/tiff image/avif image/heif image/svg+xml" + "mpv.desktop:video/mp4 video/x-matroska video/webm video/quicktime video/x-msvideo video/mpeg video/ogg audio/mpeg audio/flac audio/ogg audio/x-wav audio/mp4" + "org.gnome.Evince.desktop:application/pdf" + "libreoffice-writer.desktop:application/vnd.oasis.opendocument.text application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document application/rtf" + "libreoffice-calc.desktop:application/vnd.oasis.opendocument.spreadsheet application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet text/csv" + "libreoffice-impress.desktop:application/vnd.oasis.opendocument.presentation application/vnd.ms-powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation" +) + +mime_default_chosen() { + [[ -f $mimeapps_file ]] || return 1 + awk -v mime="$1" ' + /^\[/ { in_defaults = ($0 == "[Default Applications]"); next } + in_defaults && index($0, mime "=") == 1 { found = 1 } + END { exit found ? 0 : 1 } + ' "$mimeapps_file" +} + +install_default_apps() { + if ! command -v xdg-mime &>/dev/null; then + say "SKIP default applications (xdg-utils not installed)" + return 0 + fi + + local pending=() entry desktop_file mime_types mime_type + for entry in "${default_app_associations[@]}"; do + desktop_file="${entry%%:*}" + mime_types="${entry#*:}" + [[ -f /usr/share/applications/$desktop_file ]] || continue + for mime_type in $mime_types; do + mime_default_chosen "$mime_type" && continue + pending+=("$desktop_file:$mime_type") + done + done + + if (( ${#pending[@]} == 0 )); then + say "ok default applications" + return 0 + fi + + note_change + if [[ $check == true ]]; then + say "would set ${#pending[@]} default application association(s)" + return 0 + fi + + for entry in "${pending[@]}"; do + xdg-mime default "${entry%%:*}" "${entry#*:}" + done + say "set ${#pending[@]} default application association(s)" +} diff --git a/packages/blob.packages b/packages/blob.packages index 7e944fb..14d2008 100644 --- a/packages/blob.packages +++ b/packages/blob.packages @@ -126,12 +126,19 @@ tesseract-data-eng qrencode zbar -# Media +# Media: video and audio player, image viewer, PDF viewer mpv mpv-mpris imv evince +# Office and video editing +libreoffice-fresh +kdenlive + +# Default application associations, set by install/steps/apps.sh +xdg-utils + # Files nautilus nautilus-python