-
I want to show the list of open windows in wofi using Alt and Tab keys. Do you have a solution? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 17 replies
-
1 - no shit, xlsclients only works on xorg, who would've thought? 2 - read the wiki... |
Beta Was this translation helpful? Give feedback.
-
In case it'll be useful to someone, I've wrote a similar script that also handles full screen apps. EDIT: 23 Oct 2022 - switched to gojq ( #!/usr/bin/env bash
# rofi -show window for Hyprland, basically
state="$(hyprctl -j clients)"
active_window="$(hyprctl -j activewindow)"
current_addr="$(echo "$active_window" | gojq -r '.address')"
window="$(echo "$state" |
gojq -r '.[] | select(.monitor != -1 ) | "\(.address) \(.workspace.name) \(.title)"' |
sed "s|$current_addr|focused ->|" |
sort -r |
tofi --fuzzy-match true)"
addr="$(echo "$window" | awk '{print $1}')"
ws="$(echo "$window" | awk '{print $2}')"
if [[ "$addr" =~ focused* ]]; then
echo 'already focused, exiting'
exit 0
fi
fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")"
if [[ "$window" != "" ]]; then
if [[ "$fullscreen_on_same_ws" == "" ]]; then
hyprctl dispatch focuswindow address:${addr}
else
# If we want to focus app_A and app_B is fullscreen on the same workspace,
# app_A will get focus, but app_B will remain on top.
# This monstrosity is to make sure app_A will end up on top instead.
# XXX: doesn't handle fullscreen 0, but I don't care.
notify-send 'Complex switch' "$window"
hyprctl --batch "dispatch focuswindow address:${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:${addr}; dispatch fullscreen 1"
fi
fi
|
Beta Was this translation helpful? Give feedback.
-
Are there any plans for a "nice" Alt-Tab feature like in windows, kde, etc.? Maybe it's not what a window manager should do, but if you have a single P.S. Maybe there is a separate app for that, let me know. |
Beta Was this translation helpful? Give feedback.
-
This is what I've ended up doing to have icons #!/usr/bin/env python3
import gi
import sys
import os
import json
import re
import array as arr
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def resolveIconPath(iconName):
iconTheme = Gtk.IconTheme.get_default()
iconFile = iconTheme.lookup_icon(iconName.lower(), 32, 0)
if iconFile:
return iconFile.get_filename()
else:
return ""
def mapWindow(w):
return "img:%s:text:%s"%(resolveIconPath(w["class"]), "%s (%s_%s)"%(w["title"], w["address"], w["workspace"]["id"]))
windows = json.loads(os.popen("hyprctl -j clients").read())
filtered_windows = list(filter(lambda w: w["workspace"]["id"] != -1, windows))
mapped_windows = list(map(mapWindow, filtered_windows))
print(mapped_windows)
selected_window = os.popen("echo \"%s\" | wofi -S dmenu"%("\n".join(mapped_windows))).read()
print("selected_window: %s"%(selected_window))
if (selected_window):
match = re.search(r"\((\w+)\)$", selected_window)
addr = match.group(1).split("_")[0]
os.system("hyprctl dispatch focuswindow address:%s"%(addr))
else:
print("no selected_window") |
Beta Was this translation helpful? Give feedback.
-
Hello, I am new to Hyperland world and to window managers in general. Can someone please explain to me why Tofi and Wofi work great and switch the window after choosing it, but Rofi only shows me the menu of windows and doesn't trigger the switch part after I choose one?
|
Beta Was this translation helpful? Give feedback.
-
I have to recommend my perl script, perl is good at it! # by vincentaxhe from China
#!/bin/perl
use strict;
use utf8;
use JSON;
use Getopt::Std;
my $usage = "Usage: $0 -[fcm]";
getopts("fcm", \my %options) or die $usage;
my %arg = reverse %options or die $usage;
my $mode = $arg{1};
my $clients_json = qx(hyprctl -j clients);
my $activeworkspace_json = qx(hyprctl -j activeworkspace);
my $clients = decode_json $clients_json;
my $activeworkspace = decode_json $activeworkspace_json;
my $workspacename = $activeworkspace->{name};
my @sortedwindows = sort {$a->{focusHistoryID} <=> $b->{focusHistoryID}} @$clients;
my (@addressarr, @menuarr);
my $i = 0;
foreach my $window (@sortedwindows){
if ($window->{title}){
push @addressarr, $window->{address};
push @menuarr, join "\t", $i++, "workspace:".$window->{workspace}{name}, $window->{title};
}
}
my $menu = join "\n", @menuarr;
my %promt = (f => "focuswindow", c => "close window", m => "movetoworkspace $workspacename");
my $out = qx(echo "$menu"|wofi --dmenu -W 40% -O alphabetical -p "$promt{$mode}") or die;
my $index = (split /\t/, $out)[0];
my $dest = $addressarr[$index] or die;
my %hyprdispatchs = (
f => ["hyprctl", "dispatch", "focuswindow", "address:$dest"],
c => ["hyprctl", "dispatch", "closewindow", "address:$dest"],
m => ["hyprctl", "--batch", "dispatch focuswindow address:$dest; dispatch movetoworkspace $workspacename"]
);
exec $hyprdispatchs{$mode}->@*; hyprland.conf is like this
The script can focus to window, close window, bring window to current workspace. |
Beta Was this translation helpful? Give feedback.
1 - no shit, xlsclients only works on xorg, who would've thought?
we have
hyprctl clients
??2 - read the wiki...
hyprctl dispatch focuswindow <window>