-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathddan.sh
executable file
·50 lines (38 loc) · 2.58 KB
/
ddan.sh
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
#!/usr/bin/env bash
#guakify.sh
#Developed by Shivam Sharma. 2017.
#This is a simple script to "guakify" any application on your desktop. I use it to "guakify" my gnome-terminal (which I prefer over the Guake terminal).
#What does "guakify" mean?
#=========================
#There is a terminal application called "Guake". Its nifty feature is that it can be quickly summoned using <F11> key, and made to go away using the same key. However, I always loved gnome-terminal better than guake as the former looked better integrated. So, I developed this small script for guakifying gnome-terminal. However, I after writing this script, I realized that this could be used to "guakify" any given application. So, now you can "guakify" you browser, your word processor or any given application :)
#REQUIREMENTS
#============
#This script has these dependencies:
#* wmctrl
#* xdotool
#* awk
#* xwininfo
##### User Window Selection #####
winID=`xwininfo | grep "Window id:" | awk '{print $4}' | xargs printf 0x0%x`
##### Deciphering Window Class and Process (Command used to intiate the process) #####
winClass=`wmctrl -lpx | grep $winID | awk '{print $4}'`
winCommand=`wmctrl -lpx | grep $winID | awk '{print $3}' | xargs -I{} ps -q {} -o comm=` #Name of the Command with which window was run from
##### User Input #####
echo -e "We have automatically extracted the settings for your application. Kindly check if they are okay; otherwise provide your own values.\n\n"
read -p "Class for this window. This value should be correct. You can accept the default. (default:$winClass) " userClass
read -p "Command for this window. This value may be wrong, so input a new value if your know. (default:$winCommand) " userCommand
if [[ -n $userCommand ]]; then winCommand=$userCommand; fi;
if [[ -n $userClass ]]; then winCommand=$userClass; fi;
##### Variables to be set in final script ######
settingCommand='appCommand="'"$winCommand"'" #Command to run if our application is not running currently'
settingClass='windowClass="'"$winClass"'" #Class of the application window'
##### Setting the generated script's name ######
scriptName="guakified-$winCommand.sh"
##### Generating final script ######
cat boilerplate/bp_header.txt > $scriptName
echo $settingCommand >> $scriptName
echo $settingClass >> $scriptName
cat boilerplate/bp_maincode.txt >> $scriptName
chmod +x $scriptName
echo "Congratulations. Your script has been generated by the name: $scriptName.
Now, move this script into a folder which is in your path (maybe ~/bin/). And then assign a hotkey to initiate this script using your graphical window manager (e.g. KDE, Unity etc.)"