Warn about the danger of unplugging the USB stick before shutting down
While discussing !1586 with @intrigeri he suggested changing the behavior when the USB stick is unplugged. Right now, this triggers an emergency shutdown: https://tails.net/doc/first_steps/shutdown/.
We wondered whether too many people use this feature too lightly and how much this might lead to corrupted Persistent Storage file system.
Instead of triggering an emergency immediately and in all situation, maybe we should:
- If there is not Persistent Storage, trigger the emergency shutdown as we're doing right now.
- If there is a Persistent Storage, we could instead:
* Display a warning to discourage people from unplugging when there is not emergency
* Allow to press any key to trigger the emergency shutdown anyway from the warning
* ~~Trigger a `sync` on the USB stick~~ (impossible)
* Have a short timeout before doing an emergency shutdown anyway
# Remaining design questions
* Could we also trigger automatically a `sync` on the USB stick when the screen gets locked and still trigger the emergency shutdown when the screen is locked?
* What could be other causes of file system corruption on the Persistent Storage that we could help prevent upfront?
# To Do
* [ ] Design the UI/UX
* [x] Write some code to "bubble up" from the udev event up to some UI
* [x] Configure memlockd to keep this code in memory
* [ ] Report upstream about `--no-ok` and `--auto-close` (@sajolida)
# Implementation ideas
- Zenity? Zenity progress bar?
* We will not go as far as we want, but maybe this could be enough anyway?
* Easy to reach a first working prototype
* Easy to memlock
- GNOME Shell extension that acts as a modal dialog and lock the screen and grabs the focus and keyboard? Javascript! Ask help from the Applications Team.
* We can probably steal the code from some Gnome extension, but how maintainable is it (for us, not super-savvy in that are)?
- Learning JS (in the context of GNOME Shell) requires some investment, but it could be worth it for the future, because of how much we rely on GNOME.
- Python + Gtk. Can we have a UI as integrated as what we could do with GNOME a Shell extension? Problem: memlock-ing Python is hard.
* How do we create something that is well integrated in the desktop?
* How easy it is to memlock? Probably more complicated than a GNOME Shell extension?
- Go
* Easier to memlock than Python?
* How good are the Gtk bindings?
* Do we want to invest in using more languages?
- We're using it anyway in other areas of code
- Good example of where it would be beneficial to have a single binary.
- Rust: no way!
# Zenity
```
for i in $(seq 0 20 100) ; do
echo $i
sleep 1
done | zenity --progress --title "" --text "<b>Unplugging your USB stick can damage your Persistent Storage.</b>\n\nUse the Power Off button in the System Menu instead.\n\nTails will shut down automatically in 5 seconds.\n" --cancel-label="Showdown Now" --ok-label="" --auto-close
```

issue