Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add personal-files slot for mutt configuration #13

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/plug-declaration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"personal-files": { "allow-installation": true }
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ snap install mutt

<p align="center">Published for <img src="https://raw.githubusercontent.com/anythingcodes/slack-emoji-for-techies/gh-pages/emoji/tux.png" align="top" width="24" /> with :gift_heart: by Snapcrafters</p>

## Snap Configuration

| option | default | description |
| --------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `use-real-home` | `false` | If set to `true`, `mutt` will look for configuration in your home directory in either `$HOME/.muttrc`, `$HOME/.mutt` or `$HOME/.config/mutt`, rather than using configuration stored inside the Snap's user data directory. |

You can change Snap configuration by running `snap set mutt <key>=<value>`. For example, `snap set mutt use-real-home=true`.

## How to contribute to this snap

Thanks for your interest! Below you find instructions to help you contribute to this snap.
Expand Down
11 changes: 11 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail

# On Fedora $SNAP is under /var and there is some magic to map it to /snap.
# We need to handle that case and reset $SNAP
SNAP="${SNAP//\/var\/lib\/snapd/}"

use_real_home="$(snapctl get use-real-home)"
if [[ -z "$use_real_home" ]]; then
snapctl set use-real-home=false
fi
14 changes: 14 additions & 0 deletions snap/local/bin/mutt-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

# Run the configure hook which sets defaults for any config options
"${SNAP}/snap/hooks/configure"

export HOME="$SNAP_USER_COMMON"

use_real_home="$(snapctl get use-real-home)"
if [[ "${use_real_home}" == "true" ]]; then
export HOME="$SNAP_REAL_HOME"
fi

exec "${SNAP}/usr/local/bin/mutt" "$@"
17 changes: 15 additions & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ architectures:
apps:
mutt:
environment:
HOME: "$SNAP_USER_COMMON"
TERMINFO_DIRS: $SNAP/lib/terminfo:$SNAP/usr/share/terminfo
command: usr/local/bin/mutt
command: bin/mutt-wrapper
plugs:
- network
- home
- dot-mutt

plugs:
dot-mutt:
interface: personal-files
write:
- $HOME/.mutt
- $HOME/.muttrc
- $HOME/.config/mutt

parts:
mutt:
Expand Down Expand Up @@ -133,3 +141,8 @@ parts:
tic -xe alacritty,alacritty-direct $CRAFT_PART_SRC/alacritty.info -o .
mkdir -p $CRAFT_PRIME/lib/terminfo/a/
cp a/alacritty* $CRAFT_PRIME/lib/terminfo/a/

local-parts:
plugin: dump
source: ./snap/local
source-type: local
Loading