Hi.
Is there any application launcher for Sway that doesn't require xwayland?
You could fire up a wayland based terminal with a specified geometry and
placement that is running fzf inside it. Here's an example in a blog post
about it: https://medium.com/njiuko/using-fzf-instead-of-dmenu-2780d184753f
On Sat, Sep 23, 2017 at 12:38 AM, gnidorah notifications@github.com wrote:
Hi.
Is there any application launcher for Sway that doesn't require xwayland?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/SirCmpwn/sway/issues/1367, or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgP3_8jq_dAO1l6WHwGcOPBpAJelhWks5slKdJgaJpZM4PhdpL
.
--
Bearcat M. Şándor
Feline Soul Systems LLC
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
There's bemenu but it has some issues.
Thanks. We should wait then.
@gnidorah see the wayland branch of https://github.com/michaelforney/dmenu
That is swc-specific, does not work on Sway.
oh, well shoot
@bearcatsandor Funny solution, thanks. Would be nice to find .desktop files parser for that to get something similar to i3-dmenu-desktop/j4-dmenu-desktop
i3-dmenu-desktop works on sway.
@SirCmpwn That's what I currently use, but It uses dmenu which requires xwayland
I use compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec launched in a terminal with a specific window class, and configure sway to float and position that window. it works pretty well.
For what it's worth, i'm no longer having focus issues with rofi after upgrading to 1.4.1.
still have focus issue with rofi 1.5.1 and sway 0.15
@jbg could you explain your solution a bit?
compgen -c lists commands on your PATH, sort -u gets rid of duplicates and puts it in alphabetical order, fzf shows an interactive interface to select one of those commands and outputs the selected command on stdout, xargs -r swaymsg -t command exec tells sway to run the selected command. if you bind a key to run this pipeline in a terminal with a specific window class, you can style that terminal in your sway configuration. i make it floating and small
@jbg Thank you. This part is still unclear for me:
terminal with a specific window class
How can I change window style in wayland/sway?
@alexryndin In 1.0 version albert (simmilar to rofi) is alive so maybe so maybe rofi will also work without any problem.
Yeah I think rofi works fine on sway master.
@jbg Hi, I am curious about your solution. However, I can not figure out how to launch a terminal window with a specific class in sway. Any help appreciated
@alexryndin @KubqoA I don't think there is an easy way to change window classes, but you can use specific criteria of that window to customize it. See the Criteria section on sway's man page. I thought the best way would be to mark that terminal window upon launch and then use [con_mark="whatevermark"], but unfortunately that doesn't work since for some reason it is always the previously focussed window that is being marked instead of the new one. I've worked around this by launching the terminal window with a specific title (I guess most terminals support this) and then using that title as a criterion for customization commands. So my full command with gnome-terminal looks like this:
set $menu gnome-terminal --title Menu --hide-menubar --command "bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'", for_window [app_id="gnome-terminal-server" title="Menu"] border pixel 0, for_window [app_id="gnome-terminal-server" title="Menu"] floating enable
(You can see the attributes of all open windows with swaymsg -t get_tree)
How can I change window style in wayland/sway?
I can not figure out how to launch a terminal window with a specific class in sway. Any help appreciated
I don't think there is an easy way to change window classes
Classes (and instances) are specific to X11. Wayland has a similar thing called app_id. The good news is on Sway we can see all three of them and apply criteria to all of them too. As for how to set the class, you need to check the man page for the terminal you're running, but it's usually --class or --classname or --name. Note that some terminals, when running on Wayland, will take the class argument and set it as the app_id instead. Again, check the man page of the terminal you're running.
I thought the best way would be to mark that terminal window upon launch and then use [con_mark="whatevermark"], but unfortunately that doesn't work since for some reason it is always the previously focused window that is being marked instead of the new one.
I don't understand the steps you're doing. How are you marking the window? You shouldn't need to mark the window in this case anyway.
set $menu gnome-terminal --title Menu --hide-menubar --command "bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'", for_window [app_id="gnome-terminal-server" title="Menu"] border pixel 0, for_window [app_id="gnome-terminal-server" title="Menu"] floating enable
That's not really how it should be done. for_window adds a rule for windows matching the given criteria, and they exist until Sway exits or is reloaded. You're adding a new for_window rule every time you open your launcher.
This is how I'm doing it with termite:
bindsym $mod+r exec termite --name=launcher -e "bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'"
for_window [app_id="^launcher$"] floating enable, border none
I don't understand the steps you're doing. How are you marking the window? You shouldn't need to mark the window in this case anyway.
I was marking it with swaymsg mark whatever and I was trying to do so to have a command that works with any terminal. Because for example with gnome-terminal --name and --class have no effect, only --title changes the name. Whereas with Tilix it is the other way around.
That's not really how it should be done. for_window adds a rule for windows matching the given criteria, and they exist until Sway exits or is reloaded. You're adding a new for_window rule every time you open your launcher.
Yes, you're right. I wasn't aware of that, makes much more sense to define the customization outside of the menu command.
This is how I'm doing it with termite:
bindsym $mod+r exec termite --name=launcher -e "bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'" for_window [app_id="^launcher$"] floating enable, border none
I modified this so it lets you select from the .desktop files at /usr/share/applications and launch them with gtk-launch:
bindsym $mod+n exec termite --name=launcher -e "bash -c 'find /usr/share/applications -name *.desktop | xargs basename -s .desktop -a | fzf | xargs -r swaymsg -t command exec gtk-launch'"
It works for most apps, but some, like dconf-editor, do not launch properly.
This is how I'm doing it with termite:
bindsym $mod+r exec termite --name=launcher -e "bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'"
for_window [app_id="^launcher$"] floating enable, border none
I modified this so you can also execute arbitrary commands, like you can with dmenu/rofi:
bindsym $mod+r exec termite --name=launcher -e "bash -c 'compgen -c | sort -u | fzf --no-extended --print-query | tail -n1 | xargs -r swaymsg -t command exec'"
for_window [app_id="^launcher$"] floating enable, border none
If fzf finds a match, this will be executed. Else, what you typed will be executed.
I modified this so you can also execute arbitrary commands, like you can with dmenu/rofi:
bindsym $mod+r exec termite --name=launcher -e "bash -c 'compgen -c | sort -u | fzf --no-extended --print-query | tail -n1 | xargs -r swaymsg -t command exec'" for_window [app_id="^launcher$"] floating enable, border noneIf fzf finds a match, this will be executed. Else, what you typed will be executed.
If anyone is interested, I made a script based on this (still uses fzf).
The difference is that this script keeps a command history sorted by usage.
You can get it in my GitLab repo.
Bemenu can be used in combination with j4-dmenu-desktop (or maybe even with i3-dmenu-desktop) for getting similar result like with dmenu (-i => ignore case switch is mandatory for bemenu to work like expected) :
set $menu j4-dmenu-desktop --dmenu="bemenu -i" --no-generic --term=kitty
Indeed there is no any focus issues with rofi on latest sway beta with wlroots. It actually doesn't have anything to do with rofi and still reproduces with latest, not beta sway with wlc.
Thanks to all of you for your great examples!
Just in case anyone's interested, here's my take, based partly on the examples in this thread:
I've written a script that launches a terminal in which the fzf-based completion takes place, depending on what mode the script was launched in.
In my sway config, I have the following:
bindsym $mod+r exec --no-startup-id bash -c '~/.config/sway/alacritty_menu commands | xargs -r swaymsg -t command exec'
for_window [app_id="alacritty-menu"] floating enable, resize set width 1000 px height 250 px
I have decided to go that route so that I have the terminal launching and completion in one, reusable place.
Best regards!
Another solution which takes history into account:
bindsym $mod+x exec termite --name=launcher -e ~/bin/launcher
for_window [app_id="^launcher$"] floating enable, border none
#!/bin/bash
HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/launch_history"
HISTSIZE=30
touch "$HISTFILE"
compgen -c | sort --unique | awk '
{ if (ARGIND == 1) valid[$1]=1 }
{ sum[$1]+=1 }
END { for (i in sum) { if (valid[i]) print sum[i],i }}' - "$HISTFILE" | \
sort --numeric-sort --reverse --key=1,1 | awk '{ print $2 }' | \
fzf --no-extended --print-query --tiebreak=index | tail --lines=1 | \
xargs -I % sh -c "swaymsg -t command exec % && echo % >> '$HISTFILE'"
echo "$(tail --lines=$HISTSIZE "$HISTFILE")" > "$HISTFILE"
Thanks @sherter! A few issues I would like to see if you have a solution for... first I really like your idea of using fzf. However, there isn't a shortcut to delete history items like with rofi. Also, if I click off the menu then it doesn't close. I also can't figure out how to get it to work with scripts or arguments. I miss my ssh quick access too. Any thoughts or suggestions for those? I know they most of it can be done with a terminal and fzf. I would also like to integrate something like emoji support too. I was using this before:
https://github.com/Mange/rofi-emoji
I know that is piling a lot on there. I think your idea of using termite though is great, or something like alacritty, which both look great with transparency.
Suggestion: write a rofi patch to add Wayland support.
Suggestion: write a rofi patch to add Wayland support.
I'll see what I can do. I would like to contribute more. I am so glad I finally switched, and the nouveau drivers aren't as bad as I thought they'd be.
bindsym $mod+r exec --no-startup-id bash -c '~/.config/sway/alacritty_menu commands | xargs -r swaymsg -t command exec' for_window [app_id="alacritty-menu"] floating enable, resize set width 1000 px height 250 px
Just for those reading that don't want their window in the middle of their screen, and would like it on an edge more similar to dmenu, here's my modification of the for_window line, using jwilm/alacritty as the terminal.
bindsym $mod+d exec alacritty --class 'launcher' --command bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'
for_window [app_id="^launcher$"] floating enable, border none, resize set width 25 ppt height 100 ppt, move position 0 px 0 px
Seen out there: https://hg.sr.ht/~scoopta/wofi
I've been testing out wofi since @blaggacao mentioned it, and can recommend it as as a fast, functional cairogtk3-based dmenu replacement now that wofi/#37 is fixed (lack of cache invalidation clogging dynamic scripts) . I think we can close this as a community meta-issue :smile:, thanks ~scoopta! :rocket:
https://github.com/Cloudef/bemenu is just as easy:
pacman -S bemenu-wlroots
set $menu bemenu-run | xargs swaymsg exec --
Most helpful comment
I use
compgen -c | sort -u | fzf | xargs -r swaymsg -t command execlaunched in a terminal with a specific window class, and configure sway to float and position that window. it works pretty well.