GithubHelp home page GithubHelp logo

i3-focus-last's People

Contributors

lbonn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

i3-focus-last's Issues

Handling of ALT key release

Without having i3-focus-last installed (yes, not the ideal way for opening first issue, but most apps have this problem, which I will mention now), I want to ask about the ALT key release behavior.

Most implementations of similar software simply ignore the ALT key release for accepting the new MRU list. For example, https://github.com/altdesktop/i3ipc-python/blob/master/examples/i3-cycle-focus.py uses a delay as a workaround.

So, in my opinion, after an ALT+Tab is detected, the MRU should only be committed after the ALT key has been released. I found this to be a working solution for that (Key-up detection without interfering with other processes):

#!/usr/bin/env python3
import asyncio
from evdev import InputDevice, ecodes, list_devices

async def monitor_key_events():
    # Find the keyboard device
    devices = [InputDevice(path) for path in list_devices()]
    keyboard_device = None

    for device in devices:
        if "keyboard" in device.name.lower():
            keyboard_device = device
            break

    if not keyboard_device:
        print("Keyboard device not found")
        return

    print(f"Monitoring key events on {keyboard_device.name}")

    # Monitor key events
    async def read_events(device):
        while True:
            event = await device.async_read_one()
            yield event

    async for event in read_events(keyboard_device):
        if event.type == ecodes.EV_KEY:
            if event.code == ecodes.KEY_LEFTMETA:
                if event.value == 0:  # Key release
                    print("Left WIN key released!")

async def main():
    task = asyncio.create_task(monitor_key_events())
    await task

if __name__ == "__main__":
    asyncio.run(main())

With this approach, you can detect the ALT key being released, even when i3 is binding that key, and the key is not "grabbed" or the key event is not stolen.

I apologize for not writing a clear issue, but I only wanted to share some thoughts/issues that I came across during my research over the past few days.

By the way, the Rofi plugin idea could be exactly the right direction. Do you also display the workspace number and process names (+ window title) as in Rofi window mode?

`unknown variant `dockarea`` error when running server

Hi,

When I run cargo run --release server from the project root in the latest master version, I get the following:

❯ cargo run --release server
    Finished release [optimized] target(s) in 0.01s
     Running `target/release/i3-focus-last server`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `dockarea`, expected one of `root`, `output`, `workspace`, `con`, `floating_con`", line: 1, column: 13502)', src/main.rs:110:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

wish: provide a better error message when Rofi is not installed

After I thought I had moved all my utilities to Fuzzel and dmenu, I was focused when this quit working and started giving this error instead:

3-focus-last menu
thread 'main' panicked at 'Failed to launch menu: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:260:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I understand now that it's rofi that's not found, but it might save others some time if the message as clearer.

systemd example

Here's an example systemd unit if someone wants to use that to run the server instead of exec_always. While this is not known to crash, systemd would handle restarting it on crash automatically.

Note that you'll need to customize the ExecStart= line to match the path on your system.

Also, this expects sway-session.target to be defined. One source of that file is https://github.com/alebastr/sway-systemd

Place the file at ~/.config/systemd/user/i3-focus-last.service.

Use systemctl --user enable --now to start it and have it start automatically in the future.

(I would have added this to the wiki, but it doesn't appear enabled).

[Unit]
Description="Store the state of the last window focused"
After="sway-session.target"
PartOf="sway-session.target"

[Service]
ExecStart=/home/mark/.local/bin/i3-focus-last server
Restart="on-failure"
RestartSec=5

[Install]
WantedBy=sway-session.target

Update swayipc dep

Currently this depends on an alpha version of swayipc-rs. The project has since released a stable 3.0.0 release the dependency here can be updated.

crash

I periodically get crash with information about i3-focus-last.

$ rustc -V
rustc 1.47.0

IMG_20201026_224440

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.