-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
show_desktop.sh
executable file
·59 lines (51 loc) · 1.76 KB
/
show_desktop.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
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# This file is part of eRCaGuy_dotfiles: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles
# GS
# 23 June 2023
# DESCRIPTION:
# Toggle showing the desktop / hiding/showing all windows.
# INSTALLATION INSTRUCTIONS:
#
# Option 1: follow my online instructions: https://askubuntu.com/a/1474575/327339
#
# Option 2:
#
# 1. Install dependencies:
#
# sudo apt update
# sudo apt install wmctrl
#
# 2. Create a symlink in ~/bin to this script so you can run it from anywhere.
#
# cd /path/to/here
# mkdir -p ~/bin
# ln -si "${PWD}/show_desktop.sh" ~/bin/show_desktop # required
# ln -si "${PWD}/show_desktop.sh" ~/bin/gs_show_desktop # optional; replace "gs" with your initials
#
# 3. Re-source your ~/.profile file in Ubuntu.
#
# . ~/.profile
#
# 4. Now you can use this command directly anywhere you like in any of these ways:
#
# show_desktop
# gs_show_desktop
# REFERENCES:
# 1. *****+ this answer here: https://askubuntu.com/a/905480/327339
# 1. and my answer here too: https://askubuntu.com/a/1109490/327339
# 1. show_desktop_with_wmctrl.sh -
# https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/bash/show_desktop_with_wmctrl.sh
# 1. Note: if `wmctrl` ever quits working in a new desktop environment in the future, try using
# `ydotool` instead! See my "bash/show_desktop_with_ydotool.sh" example program mentioned in the
# top of my answer here: https://askubuntu.com/a/1109490/327339
# Toggle showing the desktop vs windows
toggle_windows() {
status="$(wmctrl -m | grep "showing the desktop" | grep -Eo "ON|OFF")"
if [ $status == "ON" ]; then
wmctrl -k off
else
wmctrl -k on
fi
}
toggle_windows
# Note: the user can press Windows + D to toggle back