Skip to content

Conversation

@lee-b
Copy link

@lee-b lee-b commented Dec 23, 2025

Add Configurable Display of Keyboard Shortcuts on Command Bar Buttons

WARNING: written by AI, but under strict guidance to do the minimal best-practice changes with respect for the existing code, verify heavily, etc., and briefly reviewed by myself.

Overview

This PR adds a new feature to the Sunflower file manager that allows users to display keyboard shortcuts on the command bar buttons, similar to how the action buttons are displayed at the bottom of Norton Commander and Midnight Commander.

Fixes: #120

Screenshot

image

What does this change do?

  • Adds a checkbox setting "Show keyboard shortcuts on command bar buttons" in the Display preferences
  • When enabled, command bar buttons show labels like "Copy (F5)" instead of just "Copy"
  • Uses the actual configured shortcuts dynamically, so custom shortcut changes are reflected
  • Labels update when preferences are saved
  • Prioritizes function keys (F1-F12) for display when multiple shortcuts are configured, matching Norton Commander tradition, and attempting to consistency and the faster keys in the command bar.

Why is this useful?

This improves user safety by allowing users to easily verify which keyboard shortcut corresponds to each button, reducing the chance of accidental operations. Personally, even though some of the shortcuts are in muscle memory, I always want to look at the command bar and verify the short cut before starting a bunch of operations, as the Copy/Delete/Move function keys can be "a little close" at the best of times ;) This is especially true when adopting a new file manager for the first time. #120 suggests that other users feel the same way.

Files Changed

  1. sunflower/gui/main_window.py

    • Added _command_bar_buttons list to track button references with accelerator mappings
    • Added _update_command_bar_labels() method to update button labels with function key prioritization
    • Added show_command_bar_shortcuts config option (default: False)
    • Integrated label updates in apply_settings()
  2. sunflower/gui/preferences/display.py

    • Added checkbox widget for the setting
    • Added load/save handlers for the option

Default Behaviour

The feature is disabled by default to preserve existing behaviour.

NOTE: I'll be submitting a separate, second PR on top of this to enable by default, so that can be easily rejected independently, if necessary.

@MeanEYE
Copy link
Owner

MeanEYE commented Dec 23, 2025

Thanks for taking the time. On a first glace it looks okay but am too tired at the moment to review code. I'll take a look tomorrow.

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.

Show keyboard shortcuts in the command bar

2 participants