-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpoweroff
More file actions
executable file
·24 lines (19 loc) · 804 Bytes
/
Copy pathpoweroff
File metadata and controls
executable file
·24 lines (19 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Decription
# ----------
# Gracefully closes all running X applications, then powers off the computer.
# Make sure to avoid conflicts with system `poweroff` is such exists.
# Useful to avoid issues when calling `poweroff` from console:
#
# * "The database you are trying to open is locked by another instance of KeePassXC.",
# * "Well, this is embarrassing. Firefox is having trouble recovering your windows and tabs."
# * Spotify forgetting current playlist
# * etc
# Author: [Dmitry](http://dmi3.net) [Source](https://github.com/dmi3/bin)
# Requirements
# ----------
# 1. `sudo apt-get install wmctrl`
setsid bash -c "sleep 3 && systemctl poweroff"&
echo "Shutdown in 3 seconds"
WIN_IDs=$(wmctrl -l | awk '{print $1}')
for i in $WIN_IDs; do wmctrl -ic "$i" || true; done