Skip to content

Read active tab command-line args from file when reappearing#172

Open
colorfulfool wants to merge 7 commits into
better-ecosystem:mainfrom
colorfulfool:read-tab-from-file
Open

Read active tab command-line args from file when reappearing#172
colorfulfool wants to merge 7 commits into
better-ecosystem:mainfrom
colorfulfool:read-tab-from-file

Conversation

@colorfulfool

@colorfulfool colorfulfool commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Hi,

This one's a bit esoteric, so I understand if you don't want to merge it.

I have multiple icons that trigger better-control and, in continuation of my first PR, would be cool if it would reappear with the corresponding tab open rather than whichever was open last time:

2025-11-18-230201_hyprshot

There's no way to pass an argument with SIGUSR1, so instead I'm writing to a file in /tmp and have better-control read it when reappearing:

#!/usr/bin/env bash

PID=`pidof better-control`
if [ -n "$PID" ]; then
  mkdir -p /tmp/better-control
  echo $@ > /tmp/better-control/tab.txt
  kill -SIGUSR1 $PID
else
  better-control $@
fi

The script then accepts the same arguments as better-control itself:

toggle-better-control -w

I had to extract the tab argument logic because it's used in two places now, hope src/utils/tab_name.py is the right place for it.

@colorfulfool colorfulfool marked this pull request as draft November 18, 2025 21:16
@colorfulfool colorfulfool marked this pull request as ready for review November 18, 2025 21:42
@quantumvoid0

Copy link
Copy Markdown
Member

you can open specfic tabs with the cmdline

@colorfulfool

Copy link
Copy Markdown
Contributor Author

you can open specfic tabs with the cmdline

Yes, but then I have to relaunch better-control every time, which takes about a second on my laptop. Maybe everyone else uses only top-of-the-line computers where PyGTK loads instantly, but I don't, and I'm contributing in case it's useful.

This PR reuses your command-line params logic, by the way.

@quantumvoid0

Copy link
Copy Markdown
Member

im a bit short on time with some other stuff so this might take few days as i cant test it out or review for bugs

@quantumvoid0

quantumvoid0 commented Dec 1, 2025

Copy link
Copy Markdown
Member

@colorfulfool so as i run the script the window just crashes without any error messages...even tho the terminal session doesnt crash the window just disappears..any idea why this might be happening?

@colorfulfool

Copy link
Copy Markdown
Contributor Author

@quantumvoid0 You mean just the window disappears? Well, it's supposed to disappear. And reappear on the next run of the script, and so on:

output.mp4

If you mean that the program exits -- you're running the script against this version, right? Because the last released version exits upon receiving SIGUSR1.

@quantumvoid0

Copy link
Copy Markdown
Member

oh well i'll test it out today (been a bit busy this month , so sorry for the late replies)

@FelipeFMA

Copy link
Copy Markdown
Member

@quantumvoid0 have you tested it?

@quantumvoid0

Copy link
Copy Markdown
Member

sadly i still havent , i havent gotten around to finding the time to work on BC for a while

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants