Skip to content

Commit

Permalink
Add system settings actions and improved file navigation
Browse files Browse the repository at this point in the history
Added actions to open system settings in the Wox plugin 'sys.go' and updated the ShellOpen function to support both MacOS and Windows. Also, a new feature was included in 'selection.go' to open the containing folder when a single file path is identified, improving file navigation in the system.
  • Loading branch information
qianlifeng committed Mar 30, 2024
1 parent 2d55b6a commit 51d950d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Wox/plugin/system/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package system

import (
"context"
"path"
"strings"
"wox/plugin"
"wox/util"
Expand Down Expand Up @@ -97,6 +98,20 @@ func (i *SelectionPlugin) queryForSelectionFile(ctx context.Context, filePaths [
},
},
})
if len(filePaths) == 1 {
results = append(results, plugin.QueryResult{
Title: "Open containing folder",
Icon: plugin.NewWoxImageBase64(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABCUlEQVR4nO2VMWrDQBBFp8gRQhoFV5a0pM0Zci/fRAK7CcJd0gXcRfKALxFIZ4OdA+gbxZ1A3nU1A/4Pfv/f7OyuCCGEEDICS3lGJQ1q+UMtSEolC3FTvpZDcnFvErhM/vbyXiRwy9p4lMBQYPUAfGVAVwAabNMVPTazX3w+vaUJDOXb3L64jtLmPT4eX+MCw+Sty+pENrOfuICHtdGpUyj6uIB1Sb0eCoAnELhCV7FeEfASq/2UwWdU7ScNfmTqMxLDuiAooPZTBldI7ScNXmL1GbmHZ/RkXRJT2YZjXGBbrh0LNAkCoYCWe/OyOk55wO5lHhX4l/jOM2h4d7JOp2HyyeUJIYTcFWcLXG7i+rfwxwAAAABJRU5ErkJggg==`),
Actions: []plugin.QueryResultAction{
{
Name: "Open containing folder",
Action: func(ctx context.Context, actionContext plugin.ActionContext) {
util.ShellOpen(path.Dir(filePaths[0]))
},
},
},
})
}

if util.IsMacOS() {
// share with airdrop
Expand Down
14 changes: 14 additions & 0 deletions Wox/plugin/system/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ func (r *SysPlugin) Init(ctx context.Context, initParams plugin.InitParams) {
plugin.GetPluginManager().GetUI().OpenSettingWindow(ctx)
},
},
{
Title: "i18n:plugin_sys_open_system_settings",
SubTitle: "",
PreventHideAfterAction: true,
Icon: sysSettingIcon,
Action: func(ctx context.Context, actionContext plugin.ActionContext) {
if util.IsMacOS() {
util.ShellRun("open", "-a", "System Preferences")
}
if util.IsWindows() {
util.ShellRun("desk.cpl")
}
},
},
}

if util.IsDev() {
Expand Down

0 comments on commit 51d950d

Please sign in to comment.