Skip to content

feat: add linux switch to terminal#10

Open
ilyaZar wants to merge 8 commits intoSublimeText:masterfrom
ilyaZar:feat/linux-switch-to-terminal
Open

feat: add linux switch to terminal#10
ilyaZar wants to merge 8 commits intoSublimeText:masterfrom
ilyaZar:feat/linux-switch-to-terminal

Conversation

@ilyaZar
Copy link
Copy Markdown

@ilyaZar ilyaZar commented Feb 8, 2026

Fix #9

  • extends the "Switch to Terminal" command to work on Linux via xdotool (fcb4a82)

  • enables bidirectional switching between Sublime Text and the terminal for linux (fcb4a82)

  • documents the command for both macOS and Linux (previously undocumented) (3f43a01 and 570491e)

  • adds example configurations for modern GPU-accelerated terminals (8ae532d)

Testing

Tested with Ghostty, Kitty, Alacritty, WezTerm, and gnome-terminal locally on Linux Mint 21.1 (Cinnamon/X11). Its quite simple so should work whenever xdotool is installed (which can be installed everhwywhere)

regarding the error message, it looks like so if xdotool is not install but a keybinding is nevertheless set:

image

- SwitchToTerminalCommand works on Linux via xdotool
- terminal window stack with dead-window pruning
- SUBLIME_TERMINAL_OPENER_WID env var for bidirectional switching
- terminal_class setting for WM_CLASS override
… Mac

- also mention that windows does not work atm
- also "Switch to application" is imprecise; better use
  "Switch to terminal" because this is what the command does
- fix typo: keybinding -> key binding (match Sublime Text convention)
@ilyaZar ilyaZar force-pushed the feat/linux-switch-to-terminal branch from a6b8c91 to 570491e Compare February 8, 2026 20:47
Copy link
Copy Markdown
Member

@FichteFoll FichteFoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. I did not try them out but left some comments on your code that you might want to consider and address.

Comment thread readme.md Outdated
[xdotool](https://github.com/jordansissel/xdotool)).
Not currently supported on Windows.

On Linux, xdotool must be installed:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of self-explanatory, but this also means it will only work for Xorg and not Wayland.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well yes; I can only do hyperland/wayland tests atm. the last commit should work

Comment thread Terminal.py Outdated
Comment on lines +194 to +199
wid = subprocess.check_output(
['xdotool', 'getactivewindow'],
timeout=2, stderr=subprocess.DEVNULL
).decode().strip()
if wid not in _terminal_wid_stack:
_terminal_wid_stack.append(wid)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could remember the pid of the spawned terminal process and use the --pid filter of xdotool to select a window of that pid. That seems less fragile than this timeout based approach.

Comment thread Terminal.py Outdated
['xdotool', 'getwindowname', wid],
timeout=2, stderr=subprocess.DEVNULL)
# Window exists -- activate it
subprocess.Popen(['xdotool', 'windowactivate', wid])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should always check the return code of a subprocess.Popen object or directly use the check_output or run methods because otherwise you will leave zombie processes around.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread Terminal.sublime-settings Outdated
// terminal's WM_CLASS differs from its executable name (e.g. gnome-terminal
// uses "gnome-terminal-server").
// Find yours with: xdotool getactivewindow getwindowclassname
"terminal_class": ""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using null to indicate an unset value rather than an empty string.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but part of the other code had this behavior with the terminal setting; I changed both then to make the code consistent

@ilyaZar
Copy link
Copy Markdown
Author

ilyaZar commented Feb 16, 2026

@FichteFoll

thanks for the feedback ! I addressed the things you mentioned; I need a test for the final commit on my arch setup with hyperland , try to get this done by the end of this week,

cheers

- detect backend via HYPRLAND_INSTANCE_SIGNATURE env var
- add backend-dispatching helpers for window operations
- refactor xdotool calls out of main code into shared helpers
- document Hyprland in readme with bashrc snippet
@ilyaZar ilyaZar force-pushed the feat/linux-switch-to-terminal branch from e236fb0 to 7b02b24 Compare February 22, 2026 13:49
@ilyaZar
Copy link
Copy Markdown
Author

ilyaZar commented Feb 22, 2026

@FichteFoll ok works on my arch setup with wayland/hyprland and ghostty or alacritty; so everything should be fine now i hope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add Linux support for "Switch to Terminal" command

2 participants