withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.06k stars 62 forks source link

Add support for Bspwm Window Manager #1791

Open datsfilipe opened 1 year ago

datsfilipe commented 1 year ago

Sanity checks

Feature Details

Description:

With Aur's fig stable package, using Archlinux and obviously using xorg, it seems to almost work, but most of the time it doesn't, it just splits all the screens. Also, fig settings open for the first time but then crash and no longer open. Would be very cool to have a support for fig on Bspwm, it's one of the most popular window managers at linux ecosystem.

Here's a screenshot of when it "worked":

image

mschrage commented 1 year ago

Try adding bspc rule -a Fig state=floating layer=above manage=off border=off to your bspwmrc file.

Use this command to confirm that "Fig" is actually the correct WM_CLASS for the autocomplete window: xprop | grep WM_CLASS

datsfilipe commented 1 year ago

I added this but fig isn't opening anymore, so I can't test yet. Don't know what the issue is, because the error message at "fig doctor" isn't very clear. Look:

~ dtsf  5.7s | 1  fig doctor --verbose
Let's check if you're logged in...
✔ Logged into Fig

Let's check your dotfiles...
✔ ~/.bashrc contains valid fig hooks
✔ ~/.bash_profile contains valid fig hooks
✔ ~/.config/fish/conf.d/00_fig_pre.fish contains valid fig hooks
✔ ~/.config/fish/conf.d/99_fig_post.fish contains valid fig hooks

Let's make sure Fig is setup correctly...
✔ Fig bin exists
✔ PATH contains ~/.local/bin
✔ Fig Integration

Let's make sure Fig is running...
✔ Daemon

Let's see if Fig is in a working state...
✔ Figterm
✔ Insertion lock does not exist
✔ PATH and PseudoTerminal PATH match
✔ Autocomplete dev mode
✔ Plugin dev mode
✔ Mission Control is loading from the correct URL

Let's check if your system is compatible...
● Fig's support for Linux 5.19.8-arch1-1 - "Arch Linux" is in development. It may not work properly on your system.

Let's check fig diagnostic...
Failed to get context:
   0: No such file or directory (os error 2)

Location:
   fig_cli/src/cli/diagnostics.rs:271

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

✘ Doctor found errors. Please fix them and try again.

If you are not sure how to fix it, please open an issue with fig issue to let us know!
Or, email us at hello@fig.io!

Can you help me with that too?

mschrage commented 1 year ago

Can you run RUST_BACKTRACE=full fig doctor?

datsfilipe commented 1 year ago

Yes, the output is this:

~ dtsf   RUST_BACKTRACE=full fig doctor

● Fig's support for Linux 5.19.8-arch1-1 - "Arch Linux" is in development. It may not work properly on your system.

Failed to get context:
   0: No such file or directory (os error 2)

Location:
   fig_cli/src/cli/diagnostics.rs:271

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  <empty backtrace>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

✘ Doctor found errors. Please fix them and try again.
mschrage commented 1 year ago

Can you run ls /var/tmp/fig/$USER and share the output here? It looks like a socket file may have been deleted.

mschrage commented 1 year ago

Also try running fig to make sure the Desktop app is running?

datsfilipe commented 1 year ago

Running the command:

~ dtsf  5.7s  ls /var/tmp/fig/$USER
secure.socket

And fig command wasn't opening fig desktop, after I reboot the machine it started opening again. But I had to do something after reboot, because with fig and fish I wasn't able to start xorg xerver. It was saying that only console users are allowed to run x server, and after changing this rule toanybody in /etc/X11/Xwrapper.config, it said that couldn't get information about the referring console, something like that. So what I did was uninstalling fig to run startx command and reinstalling it when in bspwm.

Also about the rule you've mentioned, I couldn't see it in autocomplete popup yet, but fig desktop window have the same class, and when it opens and the rule is set, it stays in top-left corner and I can't click on the input to login, for example.

mschrage commented 1 year ago

Not sure what is going on re: xorg server. We will investigate this. cc @squili

It seems like both the Dashboard window and the autocomplete window have the same WM_CLASS. But they have different window_roles and that can be used to distinguish between them. I am not sure exactly how to do this in bspwm, but you can see the logic that is used for i3 and picom here.

I don't have access to a linux machine to test this at the moment but I believe that you can use an external_rules_command script to get autocomplete working correctly. Here is a blog post that may provide helpful examples.

You'll need to...

  1. Set up an external_rules_command script in your bspwmrc
  2. Query window role via a tool like xprop
  3. echo the desired bspwm window properties (eg. state=floating layer=above manage=off border=off)
datsfilipe commented 1 year ago

image

I did it. In bspwm external rules I was able to apply the changes just when the fig window have the role "autocomplete", but it still stuck at that position. I'm not sure if there's another way to manage it.

datsfilipe commented 1 year ago

image It appears to be opening at some weird positions now, and often it doesn't open.

mschrage commented 1 year ago

Can you share the script and your bspwmrc?

datsfilipe commented 1 year ago

Sure, here is the script:

#! /bin/sh

wid=$1
class=$2
instance=$3
consequences=$4

case "$class" in
  "Fig")
    eval "$consequences"
    WM_ROLE=$(xprop -notype -id $wid WM_WINDOW_ROLE | sed 's%WM_WINDOW_ROLE = %%')

    if [ "$WM_ROLE" == '"autocomplete"' ]; then
      echo -n "state=floating layer=above manage=off border=off"
    fi
    echo "follow=on"
    ;;
esac

Here is bspwmrc file:

#! /bin/sh

export BSPCONFIG="$HOME/.config/bspwm"

killall dunst picom sxhkd polybar
xrandr --output HDMI-1 --mode 1400x900 --brightness 0.4 &
feh --bg-fill ~/pics/wallpapers/01.jpg &
~/.config/polybar/launch.sh &
picom &
dunst &
sxhkd &

alias bc='bspc config'
alias br='bspc rule'

bspc monitor HDMI-1 -d 1 2 3 4 5 6 7 8 9 # set workspaces for HDMI-1

bc border_width 0
bc window_gap 8
bc split_ratio 0.52
bc borderless_monocle true
bc gapless_monocle false

bc external_rules_command "$BSPCONFIG/external_rules"
datsfilipe commented 1 year ago

I think now that the weird behavior was caused by this follow=on that I forgot to remove. Changing this to tiled made the autocomplete open as tiled sometimes. Removing this line, the window opened in top left again.