Skip to content

Commit

Permalink
🔧 i3: super + d => show desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianmiranda committed Jan 19, 2024
1 parent 4c98a61 commit 7555a7a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion home/.config/i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bindsym $super+$alt+0 workspace number 20
# Go to first free workspace
#
bindsym $super+o exec --no-startup-id i3-msg workspace `echo {1..20} | tr ' ' '\n' | grep -vxFf <(i3-msg -t get_workspaces | jq '.[].num' | tr ' ' '\n') | head -n 1`

bindsym $super+d exec --no-startup-id ~/.config/i3/scripts/show-desktop.sh
#
# Alt + Tab
#
Expand Down
22 changes: 22 additions & 0 deletions home/.config/i3/scripts/show-desktop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Get the active outputs (screens) and store them in an array
readarray -t active_outputs < <(i3-msg -t get_outputs | jq -r 'map(select(.active == true) | .name)')

# Find a workspace that is not displayed on any screen
unused_workspace=$(echo {1..20} | tr ' ' '\n' | grep -vxFf <(i3-msg -t get_workspaces | jq -r '.[].num' | tr ' ' '\n') | head -n 1)

# Apply the workspace change to each screen
for output in "${active_outputs[@]}"
do
# Skip empty or invalid entries
if [[ -z "$output" || "$output" == "[" || "$output" == "]" ]]; then
continue
fi

# Calculate the workspace number for this screen
workspace_to_switch=$((unused_workspace++))

# Uncomment to enable actual workspace switching
i3-msg "focus output $output" && i3-msg "workspace number $workspace_to_switch"
done
2 changes: 0 additions & 2 deletions home/.config/sxhkd/sxhkdrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ super + shift + 5
###########################################################################
super + c
~/bin/wm --go-to-by-class Code
super + d
~/bin/wm --go-to-by-class Discord
super + e
~/bin/wm --go-to-by-class FirefoxDeveloperEdition$
super + f
Expand Down

0 comments on commit 7555a7a

Please sign in to comment.