-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminal.sh
More file actions
executable file
·52 lines (45 loc) · 1.26 KB
/
terminal.sh
File metadata and controls
executable file
·52 lines (45 loc) · 1.26 KB
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
#!/bin/bash
NC='\033[m'
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
if [ -z `which xdotool` ]; then
echo "${RED}[-]${NC} ${CYAN}xdtool${NC} is not installed. Install it [Y/N]"
read choice
if [[ $choice == "Y" || $choice == "y" || $choice == "" ]]; then
sudo apt-get install xdotool
else
echo "${CYAN}[*]${NC} Exitting - NO xdtool ...."
exit 1
fi
fi
activate_window () {
window_id=$(xdotool search --pid $1 --name "terminator" | tail -1)
xdotool windowactivate $window_id
}
app="teminator"
process_name=`which terminator`
if [ -e ${process_name} ]; then
pid=$(pgrep -f terminator)
# Terminator isnt launched
if [ -z $pid ]; then
$process_name
else
# Terminal is launched
echo "[+] Terminator window PID ${pid}"
# Check current focused app
focused_app=$(xdotool getactivewindow getwindowpid)
echo "[+] Focused window PID ${focused_app}"
if [ $pid == $focused_app ]; then
xdotool getactivewindow windowminimize
exit 0
else
echo "[+] Focusing on terminator window"
activate_window $pid
fi
fi
else
echo "${CYAN}[*]${NC} Exitting - No application ${app}...."
exit 1
fi
exit 0