21
submitted 9 months ago by lemmyvore@feddit.nl to c/linux@lemmy.ml

I use multiple workspaces and I open text files all the time.

Once upon a time Mousepad used to behave sanely and would open them in a new tab if there was already an instance on the current workspace, or open a new window (on the current workspace) if there wasn't.

They broke that at some point. Now it's anybody's guess where the file will open. Maybe it opens in a tab in an existing window on this workspace. Maybe in a tab in a window on a random workspace. Maybe a new window on this workspace even though there's one open. I've given up trying to figure it out.

As a last resort I can use wmctrl to figure out how to open the files and can script a sane launcher myself – provided that the editor has --tab and --window options AND lets you specify the window instance. Mousepad has the former but not the latter.

So, do you know any editor that can do it by itself or has those options so I can do it myself? TIA

you are viewing a single comment's thread
view the rest of the comments
[-] ipsirc@lemmy.ml 6 points 9 months ago

They broke that at some point.

Feel free to write a bugreport.

[-] lemmyvore@feddit.nl 3 points 9 months ago

I think it was done on purpose.

Anyway... I figured out a workaround in my script. By focusing one of the windows on the current workspace before I open a new tab it seems to make it the preferred window. It's not foolproof, sometimes it still selects one of the other windows, but it's close enough.

Here's the script in case anybody needs it, should work with any editor that has some sort of -tab and -window options if you grep for the correct window name:

#!/bin/bash
WORKSPACE=$(
	wmctrl -d |\
	grep '*' |\
	awk '{print $1}'
)

WINID=$(
	wmctrl -l |\
	grep ' - Mousepad' |\
	grep -E "\s${WORKSPACE}\s"|\
	tail -1|\
	awk '{print $1}'
)

if [ -z "$WINID" ]; then
	exec /usr/bin/mousepad -o window "$@"
else
	wmctrl -i -a "$WINID" && \
	sleep 0.5 && \
	exec /usr/bin/mousepad -o tab "$@"
fi
this post was submitted on 21 Nov 2023
21 points (88.9% liked)

Linux

46643 readers
816 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS