H3rmt / hyprswitch

A CLI/GUI that allows switching between windows in Hyprland
https://crates.io/crates/hyprswitch
MIT License
180 stars 5 forks source link

hyprswitch still working? (new CLI args) #43

Closed aloispichler closed 2 months ago

aloispichler commented 3 months ago

Since 2.0.3, everytime hyprswitch is invoked, I am getting a notification as (1U) Hyprswitch (2.0.3) Error Unable to parse CLI Argument (visit …) Failed to parse command line arguments Caused by: error unexpected argument '--deamon and error unexpected argument '--stop-deamon

Even hyprswitch --help says: Error: “Failed to parse command line arguments” and sends the notification. Hmm… something went severely wrong.

Here is my config:

# ╭──   alttab ────────
# bind=ALT,TAB,workspace,previous
bind= ALT,   TAB,      exec, hyprswitch --daemon --sort-recent --do-initial-execute
bind= SUPER, TAB,       exec, hyprswitch --daemon --sort-recent --do-initial-execute
bind= ALT SHIFT, TAB,   exec, hyprswitch --daemon --sort-recent --do-initial-execute --reverse
# stop hyprswitch
# bindrt=ALT, ALT_L,     exec, hyprswitch --stop-daemon
bindrt= ALT, ALT_L,     exec, hyprswitch --stop-daemon
bindrt= Super, SUPER_L, exec, hyprswitch --stop-daemon
bindrn=, escape, exec, pkill hyprswitch
H3rmt commented 3 months ago

I did some breaking changes to the CLI (Split them into different sucommands) but did Not manage to merge the PR with the updated README.md (some small fixes are still Missing) (but hyprswitch --help should Work?)

Please look at the README.md in the dev branch for the updated CLI Options

Im planing to add a more detailed description for the Commands and their Options to the README

H3rmt commented 3 months ago

Examples:

(Modify the $... variables to use the keys you prefer)

Simple (No GUI)

Next Previous

# 2 Keybindings to switch to 'next' or 'previous' window
$key = TAB
$modifier = CTRL
$reverse = SHIFT

bind = $modifier, $key, exec, hyprswitch simple
bind = $modifier $reverse, $key, exec, hyprswitch simple -r

Last Focused

# 1 Keybinding to switch to previously focused application
$key = TAB
$modifier = CTRL

bind = $modifier, $key, exec, hyprswitch simple --sort-recent

Same class/type

# 2 Keybindings to switch to next' or 'previous' window of same class/type
$key = TAB
$modifier = CTRL
$reverse = SHIFT

bind = $modifier, $key, exec, hyprswitch simple -s
bind = $modifier $reverse, $key, exec, hyprswitch simple -s -r

GUI

Add exec-once = hyprswitch init & to your ~/.config/hypr/hyprland.conf to start the daemon on startup

Press $modifier + $key to open the GUI, use mouse to click on window

$key = TAB
$modifier = SUPER
$switch_release = SUPER_L

# open hyprswitch
bind = $modifier, $key, exec, hyprswitch gui

# close hyprswitch
bindr = $modifier, $switch_release, exec, hyprswitch close
# if it somehow doesn't close on releasing $switch_release, escape can kill (doesnt switch)
bindrn = ,escape, exec, hyprswitch close --kill

GUI + Keyboard Config

Complex Config with submap to allow for many different keybindings when opening hyprswitch (run hyprctl dispatch submap reset if stuck in switch submap)

$key = TAB
$modifier = ALT
$modifier_release = ALT_L
$reverse = SHIFT

# allows repeated switching with same keypress that starts the submap
binde = $modifier, $key, exec, hyprswitch gui --do-initial-execute
bind = $modifier, $key, submap, switch

# allows repeated switching with same keypress that starts the submap
binde = $modifier $reverse, $key, exec, hyprswitch gui --do-initial-execute -r
bind = $modifier $reverse, $key, submap, switch

submap = switch
# allow repeated window switching in submap (same keys as repeating while starting)
binde = $modifier, $key, exec, hyprswitch gui
binde = $modifier $reverse, $key, exec, hyprswitch gui -r

# switch to specific window offset (TODO replace with a more dynamic solution)
bind = $modifier, 1, exec, hyprswitch gui --offset=1
bind = $modifier, 2, exec, hyprswitch gui --offset=2
bind = $modifier, 3, exec, hyprswitch gui --offset=3
bind = $modifier, 4, exec, hyprswitch gui --offset=4
bind = $modifier, 5, exec, hyprswitch gui --offset=5

bind = $modifier $reverse, 1, exec, hyprswitch gui --offset=1 -r
bind = $modifier $reverse, 2, exec, hyprswitch gui --offset=2 -r
bind = $modifier $reverse, 3, exec, hyprswitch gui --offset=3 -r
bind = $modifier $reverse, 4, exec, hyprswitch gui --offset=4 -r
bind = $modifier $reverse, 5, exec, hyprswitch gui --offset=5 -r

# exit submap and stop hyprswitch
bindrt = $modifier, $modifier_release, exec, hyprswitch close
bindrt = $modifier, $modifier_release, submap, reset

# if it somehow doesn't close on releasing $switch_release, escape can kill (doesnt switch)
bindr = ,escape, exec, hyprswitch close --kill
bindr = ,escape, submap, reset
submap = reset
H3rmt commented 3 months ago

Updated Config:

# ╭──   alttab ────────
# bind=ALT,TAB,workspace,previous
bind= ALT,   TAB,      exec, hyprswitch gui --sort-recent --do-initial-execute
bind= SUPER, TAB,       exec, hyprswitch gui --sort-recent --do-initial-execute
bind= ALT SHIFT, TAB,   exec, hyprswitch gui --sort-recent --do-initial-execute --reverse
# stop hyprswitch
# bindrt=ALT, ALT_L,     exec, hyprswitch close
bindrt= ALT, ,     exec, hyprswitch close
bindrt= Super, SUPER_L, exec, hyprswitch close
bindrn=, escape, exec,  hyprswitch close --kill

Add the exec-once = hyprswitch init & from the README

H3rmt commented 3 months ago

new help:

A CLI/GUI that allows switching between windows in Hyprland

Usage: hyprswitch [OPTIONS] <COMMAND>

Commands:
  init    Initialize and run the Daemon
  gui     Starts/Opens the GUI + sends the command to daemon of GUI is already opened
  simple  Switch without using the GUI / Daemon (switches directly)
  close   Close the GUI, executes the command to switch window
  help    Print this message or the help of the given subcommand(s)

Options:
  -d, --dry-run  Print the command that would be executed
  -v...          Increase the verbosity level (max: -vv)
  -h, --help     Print help
  -V, --version  Print version
aloispichler commented 3 months ago
  1. The updated GUI config now does nothing here, that is, it does not change windows (but it does not show notifications neither).

  2. No: The result of hyprswitch --help is:

    
    Error: Failed to parse command line arguments

Caused by: A CLI/GUI that allows …


 … and then your other text is shown.

Here, hyprswitch stopped working entirely, unfortunately.
H3rmt commented 3 months ago

Can you run hyprswitch -vv init in a Terminal and check If running hyprswitch -vv gui now works

aloispichler commented 3 months ago

Yes, this works. It seems that I need to run hyprswitch -vv init first? I missed this in your post before, I am sorry. Thanks again!

H3rmt commented 3 months ago

I think an additional Toast if the daemon isn't running would be useful

zvictor commented 3 months ago

I just followed your instructions and it worked in nixos. Thank you!

hyprswitch.conf