-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoggle-coOo-Window-visibility
105 lines (101 loc) · 5.88 KB
/
toggle-coOo-Window-visibility
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
```bash
#!/usr/bin/bash
˙ ' 2024-03-07_10:19
Created for the purpose of being run on pressing the F9 key resulting in toggling
visibility of the coOo Console Window simulating drop-down behavior
oOosys : 2024-03-10_18:44 '
˙ ' ------------------------------------------------------------------------------------------------------------------------------------'
# Proper functioning of this script REQUIRES:
## -- setting [F9] as shortcut running THIS script in the [Application Shortcuts] Tab
### of the Linux Mint Xfce Keyboard dialog box
#### which can be raised running ~ $ xfce4-keyboard-settings
## -- the Console application started using the for this purpose created
### coOo executable shell script with following content ( remove ˙ ' and ' ):
˙ ' bashrcFlag="/tmp/coOoRUN"; touch $bashrcFlag # "tell" bash it was started by coOo
cd /home/o/oOo/ooo/root/usr/local/sbin # run the Console/Terminal App:
./wezterm --config-file coOo_init.lua start --always-new-process '
## -- the (customized) wezterm application along with its configuration file
### coOo_init.lua placed in /home/o/oOo/ooo/root/usr/local/sbin
## -- following code block in ~/.bashrc ( remove leading ˙ ' and trailing ' ):
˙ '#.======================================================================
# SAVE the Console WinID for later use to generate Console drop-down effect
# in case the shell was invoked by the coOo Console :
if [ -f /tmp/coOoRUN ]; then # THIS script was called by the coOo Console starting script
echo " coOo running bash \$PPID = [$PPID]" # the ID of parent process i.e. Console
# Because any in Linux Mint Xfce run process can raise multiple Windows, functions
## changing Window properties need a pointer to a Window, a WinID, so let us
### get the WinID of the Console and save it as a file name extension
#### of a file in the /tmp directory for later use by the visibility toggling script
##### toggle-coOo-Window-visibility
WinID=$(xdotool search --pid $PPID)
# sleep 0.5
wmctrl -i -r $WinID -b add,above # make the Window stay on top of all other ones
echo " coOo running bash \$PPID = [$PPID] \$WinID = [$WinID] "
# ^-- the ID of parent process i.e. Console and the WindowID of Console Window
if ls /tmp/coOoWindowID.* 1> /dev/null 2>&1; then # files with WindowID exist, so
rm /tmp/coOoWindowID.* # delete them all before creating a new one :
fi; echo -n "1" > /tmp/coOoWindowID.$WinID # mark coOo Window status as: visible
rm /tmp/coOoRUN # assure skipping the entire if [ -f /tmp/coOoRUN ] code block
## in case of other caller of bash than coOo .
fi '
## -- setting desired position and size of Console Window in coOo_init.lua script
### with configuration settings for the coOo Console application
˙ ' ------------------------------------------------------------------------------------------------------------------------------------'
coOoWindowIDfileName=$(ls /tmp/coOoWindowID.* | head -n1)
# get the first one if by mistake there are ^-- multiple files --^ there
if [ -z "$coOoWindowIDfileName" ]; then # pointer to a coOo WinID is missing so:
/usr/local/sbin/coOo # raise a new Console Window
exit
notify-send -u critical -i xfburn \
" toggle-coOo-Window-visibility " \
"EXIT missing a WinID to toggle visibility EXIT"
exit
fi
# Now it is sure that the pointer to a coOo WinID is there, so save it for later use:
WinID=${coOoWindowIDfileName##*'.'}
if xprop -id $WinID &>/dev/null; then # Window with this ID exists, so
if [ -s "$coOoWindowIDfileName" ]; then # file is there and is at least 1 byte in size, so
# ~ $ xprop -root -notype _NET_CURRENT_DESKTOP # | cut -d' ' -f3
# _NET_CURRENT_DESKTOP = 1
currWorkspaceID=$(wmctrl -d | grep '*' | cut -d' ' -f1)
# xdotool can directly get the WorkspaceID related to a WindowID so let's use it:
windWorkspaceID=$(xdotool get_desktop_for_window $WinID) #
if [ "$currWorkspaceID" -eq "$windWorkspaceID" ]; then
echo " hiding the Window with ID: $WinID"
#xdotool windowunmap $WinID # hide the Window and ...
wmctrl -i -r $WinID -b toggle,visible,hidden
> $coOoWindowIDfileName # ... indicate invisible Window
notify-send -u normal -i xfburn \
" toggle-coOo-Window-visibility " \
"INFO Window with ID=$WinID is HIDDEN INFO"
exit
fi
# Now it is sure that the window is visible, but on another Workspace, so ...
wmctrl -v -i -r $WinID -t $currWorkspaceID # ... move it to the current Workspace
# echo -n "1" > $coOoWindowIDfileName # ... indicate visible Window
notify-send -u low -i xfburn \
" toggle-coOo-Window-visibility " \
"INFO Window with ID=$WinID MOVED to THIS Workspace INFO"
exit
fi
# Now it is sure that the file is there and without content, so
echo " showing the Window with ID: $WinID"
#xdotool windowmap $WinID # show the Window and ...
currWorkspaceID=$(wmctrl -d | grep '*' | cut -d' ' -f1)
windowWorkspaceID=$(xdotool get_desktop_for_window $WinID)
wmctrl -v -i -r $WinID -t $currWorkspaceID
wmctrl -i -r $WinID -b toggle,visible,hidden
echo -n "1" > $coOoWindowIDfileName # ... indicate visible Window
notify-send -u low -i xfburn \
" toggle-coOo-Window-visibility " \
"INFO Window with ID=$WinID made VISIBLE again INFO"
exit # --sync as option to xdotool shows the window only in one Workspace
fi
# notify-send -u critical -i xfburn \
# " toggle-coOo-Window-visibility " \
# "INFO missing a Window with WinID=$WinID INFO"
rm $coOoWindowIDfileName # clean-up the mess if any
/usr/local/sbin/coOo # run the Console application
exit
# --- END of script running multiple executables ( notify-send, wmctrl, ... ) ---
```