Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show all opened windows #4121

Closed
kristoferus75 opened this issue May 3, 2019 · 15 comments
Closed

show all opened windows #4121

kristoferus75 opened this issue May 3, 2019 · 15 comments

Comments

@kristoferus75
Copy link

Hi !

I use sway 1.0

Is it possible to see all openend windows (for all workspaces) with a shell command to use it in a rofi or dmenu and to switch to this opened windows and to this workspace -> like a window switcher ? (with rofi i use it this on xfce)

thanks

kind regards

kristoferus75

@ddevault
Copy link
Contributor

ddevault commented May 3, 2019

You can probably accomplish this with swaymsg -t get_tree and [...criteria...] focus. See the man pages for details.

@ddevault ddevault closed this as completed May 3, 2019
@Emantor
Copy link
Contributor

Emantor commented May 4, 2019

bindsym $mod+g exec swaymsg \[con_id=$(swaymsg -t get_tree | jq -r '.nodes | .[] | .nodes | . [] | select(.nodes != null) | .nodes | .[] | select(.name != null) | "\(.id?) \(.name?)"' | rofi -dmenu -i | awk '{print $1}')] focus

Is my naive bindsym using jq.

@kristoferus75
Copy link
Author

Hi Emantor !

Thanks :-)

I have tested it and it shows only the tilled windows and not the floating windows and if im on an oher workspace it doesnt focus to that workspace to that windows !

Sorry i have no idea how to correct this !

Thanks

kind regards kristoferus75

@kristoferus75
Copy link
Author

Hi !

With this script it works now :

#!/bin/bash

# Get available windows
windows=$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .name?' | grep -e "[0-9]* ."  )

# Select window with rofi
selected=$(echo "$windows" | rofi -dmenu -i | awk '{print $1}')

# Tell sway to focus said window
swaymsg [con_id="$selected"] focus

kind regards

kristoferus75

@lorendias
Copy link

lorendias commented Oct 22, 2019

Edit: I realized jq wasn't installed there wasn't any error message. Installing jq fixed it. It now works.

@shapeoflambda
Copy link

shapeoflambda commented Mar 22, 2020

Tweaked the above code to make it work with floating windows:

#!/bin/bash

# Get regular windows
regular_windows=$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .name?' | grep -e "[0-9]* ."  )

# Get floating windows
floating_windows=$(swaymsg -t get_tree | jq '.nodes[1].nodes[].floating_nodes[] | (.id|tostring) + " " + .name?'| grep -e "[0-9]* ." | tr -d '"')

enter=$'\n'
if [[ $regular_windows && $floating_windows ]]; then
  all_windows="$regular_windows$enter$floating_windows"
elif [[ $regular_windows ]]; then
  all_windows=$regular_windows
else
  all_windows=$floating_windows
fi

# Select window with rofi
selected=$(echo "$all_windows" | rofi -dmenu -i | awk '{print $1}')

# Tell sway to focus said window
swaymsg [con_id="$selected"] focus

@tobiaspc
Copy link

tobiaspc commented May 1, 2020

I reimplemented the above snipped in python, removing the need to include the window id for wofi, dropping the jq dependency and improving startup time by ~40% on my laptop, running in power saving mode.

See here: https://github.com/tobiaspc/wofi-scripts

@sim590
Copy link

sim590 commented Sep 9, 2021

I was looking for something a bit more like this (coming from AwesomeWM):

https://github.com/guotsuan/awesome-revelation

It show all windows in the same workspace and lets us choose the window with a key and then it switches to the window in its workspace. Is there anything of the sort that exists nowadays? That would be very nice.

edit

I found this:

https://sr.ht/~tsdh/swayr/

Which is nice, but not as cool as the awesome-revelation mosaïque I like. I'm linking it for references.

@tmpm697
Copy link

tmpm697 commented Apr 9, 2022

@sim590 Woa, that's awsome-revelation seems overkill but very nice/handy switcher. But for it to work with sway, client needs to aware of window's location on screen. From swaymsg -t get_tree we can get window size and location on screen.

So we need to center display random character for each window and also able to read user input from that display. No idea how but that some verboses.

@davxy
Copy link

davxy commented Oct 12, 2022

@senorsmile
Copy link

I was looking for something a bit more like this (coming from AwesomeWM):

https://github.com/guotsuan/awesome-revelation

It show all windows in the same workspace and lets us choose the window with a key and then it switches to the window in its workspace. Is there anything of the sort that exists nowadays? That would be very nice.

edit

I found this:

https://sr.ht/~tsdh/swayr/

Which is nice, but not as cool as the awesome-revelation mosaïque I like. I'm linking it for references.

Also looking for something like this. I've been on sway for a little over a year now, and I realized that this is the one thing that I miss. Swayr does provide a sort of solution, but the visual aspect makes it far easier and faster to recognize and switch.

@GotaLoveFiraCode
Copy link

BTW, rofi has this feature built in: rofi -terminal '$term' -modes window -show window

@skybert
Copy link

skybert commented Jun 6, 2024

BTW, rofi has this feature built in: rofi -terminal '$term' -modes window -show window

Sadly, that doesn't show all windows. On my system, it only shows some windows, like Chrome. It doesn't show apps like Firefox, Emacs, Kitty.

$ sway --version
sway version 1.9
$ rofi -v
Version: 1.7.5

@GotaLoveFiraCode
Copy link

Huh sorry man, can't help you there! I tried it with rofi 1.7.5 too, and was fully successful — so it has to be some external factor. Good luck!

@VanLaser
Copy link

Isn't that related to how rofi sees windows, as in maybe it only sees the wayland native ones, and not the ones running through X?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests