-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclosegracefully
executable file
·112 lines (85 loc) · 2.49 KB
/
closegracefully
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
######################################################################
#
# "Close Gracfully"
#
# Author: ZyMOS
#
# Date: 2012ish
#
# Description:
# This scripts closes various programs gracfully. This means
# the programs will close the programs as it expects to quited.
# In some cases this will save the current state of the program,
# in other cases it will query the user to save current document.
# This script can be used to shutdown your computer via command-
# line without worrying about losing documents or crashing
# programs. Add more programs using examples below.
#
# Requirements: wmctrl, xdotool, pidof
#
# Usage: closegracfully
#
#######################################################################
# rtorrent
# if [[ -n `pidof rtorrent` ]];then
# echo "rtorrent is open, time to die (gracefully)...."
# (kill -2 `pidof rtorrent` &)
# fi
# mozilla firefox...
if [[ -n `pidof firefox` || -n `pidof firefox.bin` || -n `pidof firefox.real` ]];then
echo "Closing firefox..."
WID=`xdotool search "Mozilla Firefox" | head -1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+q
fi
# galeon...
# if [[ -n `pidof galeon` ]];then
# echo "closing galeon..."
# (galeon -q &)
# fi
# openoffice.org
# echo "closing openOffice (if its open)..."
# (wmctrl -c OpenOffice &)
# LibreOffice
if [[ -n `pidof soffice.bin` ]];then
echo "Closing LibreOffice..."
(wmctrl -c LibreOffice &)
fi
# DeadBeef
if [[ -n `pidof deadbeef` ]];then
echo "Closing DeaDBeeF..."
(wmctrl -c DeaDBeeF &)
fi
# Inkscape
if [[ -n `pidof inkscape` ]];then
echo "Closing Inkscape..."
(wmctrl -c Inkscape &)
fi
# Gimp
if [[ -n `pidof gimp` ]];then
echo "Closing Gimp..."
(wmctrl -c gimp &)
fi
# Pidgin...
# echo "closing pidgin (if its open)..."
# (purple-remote "quit" &)
# qBittorrent
# echo "Closing qBittorrent (if its open)..."
# (wmctrl -c qBittorrent &)
# echo "closing swiftfox (if its open)..."
# (wmctrl -c swiftfox &)
# Transmission... (may not work in minimized in tray, to fix)
if [[ -n `pidof transmission-gtk` || -n `pidof transmission-qt` ]];then
echo "Closing Transmission..."
WID=`xdotool search "Transmission" | head -1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+q
# for transmission-cli: see transmission-remote
fi
# Virtualbox
if [[ -n `pidof VirtualBox` ]];then
echo "Closing VirtualBox's in saved state..."
WID=`VBoxManage list runningvms|sed 's/.*{//'|sed 's/}//'`
VBoxManage controlvm $WID savestate
fi