Skip to content

fix: set tty mode if force_tty is true in config file#1515

Merged
aristocratos merged 1 commit intoaristocratos:mainfrom
vandabbin:fix-force-tty-config
Feb 7, 2026
Merged

fix: set tty mode if force_tty is true in config file#1515
aristocratos merged 1 commit intoaristocratos:mainfrom
vandabbin:fix-force-tty-config

Conversation

@vandabbin
Copy link
Copy Markdown
Contributor

@vandabbin vandabbin commented Jan 26, 2026

Fixes: #1514

The force_tty menu option wasn't being applied when btop launched
even though it was being saved in the config file.

This fixes this by applying tty mode if this option is set to true in the config file

@vandabbin vandabbin force-pushed the fix-force-tty-config branch 2 times, most recently from cbc8362 to 4c55d8b Compare January 27, 2026 19:05
@vandabbin vandabbin changed the title fix: set tty mode if force_tty is true in config file refactor: remove force_tty menu option Jan 27, 2026
@vandabbin vandabbin force-pushed the fix-force-tty-config branch from 4c55d8b to f7f73fd Compare January 28, 2026 18:36
@vandabbin vandabbin changed the title refactor: remove force_tty menu option fix: set tty mode if force_tty is true in config file Jan 28, 2026
Copy link
Copy Markdown
Collaborator

@deckstose deckstose left a comment

Choose a reason for hiding this comment

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

This doesn't account for --no-tty+ config file force_tty = true

@vandabbin
Copy link
Copy Markdown
Contributor Author

vandabbin commented Jan 29, 2026

This doesn't account for --no-tty+ config file force_tty = true

Oh great catch!! I forgot that there was a no-tty cli option as well!

Although this does make it trickier. The no-tty command line option would leave force_tty as true in the config file so the menu option would continue to be backwards if btop is launched with --no-tty. I will have to think about this one some more to come up with something good


I have compensated for this by changing the force_tty menu option to only toggle tty mode on if it is true and only toggle it off if it is false. I also added some platform specific code that basically disables the effect of toggling the force_tty menu option if a TTY was auto-detected (the same way it seems to be done when btop starts). I'm not 100% on the formatting I used for the compiler #if. I may have it indented poorly

  • This way the user can launch with --no-tty and if force_tty is true in the config then the cli option over rules it (which I think makes sense).
  • The menu option continues to show force_tty as true which is technically accurate (as a reflection of the config file) even if not currently in tty mode because it was done by a temporary measure (i.e. cli flag).
  • If the menu option is then toggled off tty mode is not enabled as it would have been previously when all that did was flip the option.
  • If the menu option force_tty is then toggled to true again it will reset to tty mode (overriding the cli option).
  • If a TTY has been auto-detected toggling force_tty on or off will not have any visible effect.

I could possibly figure out some changes to make the force_tty menu option reflect the cli flag as well without saving it to the config file (if set by flag) when it exits, but I am not sure it is worth the extra work

@vandabbin vandabbin marked this pull request as draft January 29, 2026 14:47
@vandabbin vandabbin force-pushed the fix-force-tty-config branch from f7f73fd to f19fd41 Compare January 29, 2026 15:08
@vandabbin vandabbin marked this pull request as ready for review January 29, 2026 15:16
@vandabbin vandabbin force-pushed the fix-force-tty-config branch 3 times, most recently from 0f82d19 to b9260bb Compare January 29, 2026 18:49
@vandabbin vandabbin force-pushed the fix-force-tty-config branch from b9260bb to 0f6c688 Compare January 29, 2026 18:54
Comment thread src/btop_menu.cpp
@aristocratos aristocratos merged commit a229e87 into aristocratos:main Feb 7, 2026
43 checks passed
@vandabbin vandabbin deleted the fix-force-tty-config branch February 7, 2026 20:47
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.

Force TTY option in config file doesn't apply when btop is started

3 participants