Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b61e665c71 | ||
|
|
8408c669ef | ||
|
|
d66066c3b6 | ||
|
|
dac55cdd0d | ||
|
|
03365d24e5 | ||
|
|
8e58654336 | ||
|
|
33e0032725 | ||
|
|
c05fff189d | ||
|
|
57d130ca51 | ||
|
|
954a6ba9c9 |
18
main.go
18
main.go
@@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/gotk3/gotk3/gtk"
|
"github.com/gotk3/gotk3/gtk"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4.0"
|
const version = "0.4.2"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
appDirs []string
|
appDirs []string
|
||||||
@@ -114,18 +114,10 @@ func defaultTermIfBlank(s, fallback string) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultStringIfBlank(s, fallback string) string {
|
|
||||||
s = strings.TrimSpace(s)
|
|
||||||
if s == "" {
|
|
||||||
return fallback
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateWm() {
|
func validateWm() {
|
||||||
if !(*wm == "sway" || *wm == "hyprland") && *wm != "" {
|
if !(*wm == "sway" || *wm == "hyprland" || *wm == "Hyprland") && *wm != "" {
|
||||||
*wm = ""
|
*wm = ""
|
||||||
log.Warn("-wm argument supports only sway or hyprland string.")
|
log.Warn("-wm argument supports only 'sway' or 'hyprland' string.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +141,7 @@ var itemSpacing = flag.Uint("spacing", 20, "icon spacing")
|
|||||||
var lang = flag.String("lang", "", "force lang, e.g. \"en\", \"pl\"")
|
var lang = flag.String("lang", "", "force lang, e.g. \"en\", \"pl\"")
|
||||||
var fileManager = flag.String("fm", "thunar", "File Manager")
|
var fileManager = flag.String("fm", "thunar", "File Manager")
|
||||||
var term = flag.String("term", defaultTermIfBlank(os.Getenv("TERM"), "foot"), "Terminal emulator")
|
var term = flag.String("term", defaultTermIfBlank(os.Getenv("TERM"), "foot"), "Terminal emulator")
|
||||||
var wm = flag.String("wm", defaultStringIfBlank(os.Getenv("XDG_CURRENT_DESKTOP"), ""), "Use swaymsg (with 'sway' argument) or hyprctl (with 'hyprland')")
|
var wm = flag.String("wm", "", "Use swaymsg (with 'sway' argument) or hyprctl (with 'hyprland')")
|
||||||
var nameLimit = flag.Int("fslen", 80, "File Search name LENgth Limit")
|
var nameLimit = flag.Int("fslen", 80, "File Search name LENgth Limit")
|
||||||
var noCats = flag.Bool("nocats", false, "Disable filtering by category")
|
var noCats = flag.Bool("nocats", false, "Disable filtering by category")
|
||||||
var noFS = flag.Bool("nofs", false, "Disable file search")
|
var noFS = flag.Bool("nofs", false, "Disable file search")
|
||||||
@@ -542,8 +534,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
statusLineWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
statusLineWrapper, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
|
||||||
|
statusLineWrapper.SetProperty("name", "status-line-wrapper")
|
||||||
outerVBox.PackStart(statusLineWrapper, false, false, 10)
|
outerVBox.PackStart(statusLineWrapper, false, false, 10)
|
||||||
statusLabel, _ = gtk.LabelNew(status)
|
statusLabel, _ = gtk.LabelNew(status)
|
||||||
|
statusLabel.SetProperty("name", "status-label")
|
||||||
statusLineWrapper.PackStart(statusLabel, true, false, 0)
|
statusLineWrapper.PackStart(statusLabel, true, false, 0)
|
||||||
|
|
||||||
win.ShowAll()
|
win.ShowAll()
|
||||||
|
|||||||
67
tools.go
67
tools.go
@@ -548,6 +548,14 @@ func savePinned() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func launch(command string, terminal bool) {
|
func launch(command string, terminal bool) {
|
||||||
|
// trim % and everything afterwards
|
||||||
|
if strings.Contains(command, "%") {
|
||||||
|
cutAt := strings.Index(command, "%")
|
||||||
|
if cutAt != -1 {
|
||||||
|
command = command[:cutAt-1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
themeToPrepend := ""
|
themeToPrepend := ""
|
||||||
// add "GTK_THEME=<default_gtk_theme>" environment variable
|
// add "GTK_THEME=<default_gtk_theme>" environment variable
|
||||||
if *forceTheme {
|
if *forceTheme {
|
||||||
@@ -557,70 +565,31 @@ func launch(command string, terminal bool) {
|
|||||||
themeToPrepend = th.(string)
|
themeToPrepend = th.(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// trim % and everything afterwards
|
|
||||||
if strings.Contains(command, "%") {
|
|
||||||
cutAt := strings.Index(command, "%")
|
|
||||||
if cutAt != -1 {
|
|
||||||
command = command[:cutAt-1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
elements := strings.Split(command, " ")
|
|
||||||
|
|
||||||
envVarsNum := 0
|
|
||||||
if strings.Contains(elements[0], "=") {
|
|
||||||
for _, element := range elements {
|
|
||||||
if strings.Contains(element, "=") {
|
|
||||||
envVarsNum++
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// find prepended env variables, if any
|
|
||||||
var envVars []string
|
|
||||||
|
|
||||||
if themeToPrepend != "" {
|
if themeToPrepend != "" {
|
||||||
envVars = append(envVars, fmt.Sprintf("GTK_THEME=%s", themeToPrepend))
|
command = fmt.Sprintf("GTK_THEME=%q %s", themeToPrepend, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdIdx := envVarsNum
|
var elements = []string{"/usr/bin/env", "-S", command}
|
||||||
firstArgIdx := envVarsNum + 1
|
|
||||||
|
|
||||||
if envVarsNum > 0 {
|
cmd := exec.Command(elements[0], elements[1:]...)
|
||||||
for idx, item := range elements {
|
|
||||||
if envVarsNum > idx && strings.Contains(item, "=") {
|
|
||||||
envVars = append(envVars, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(elements[cmdIdx], elements[firstArgIdx:]...)
|
|
||||||
|
|
||||||
var prefixCommand string
|
|
||||||
var args []string
|
|
||||||
if terminal {
|
if terminal {
|
||||||
prefixCommand = *term
|
var prefixCommand = *term
|
||||||
if *term != "foot" {
|
var args []string
|
||||||
args = []string{"-e", strings.Join(elements, " ")}
|
if prefixCommand != "foot" {
|
||||||
|
args = []string{"-e", command}
|
||||||
} else {
|
} else {
|
||||||
args = elements[cmdIdx:]
|
args = elements
|
||||||
}
|
}
|
||||||
cmd = exec.Command(prefixCommand, args...)
|
cmd = exec.Command(prefixCommand, args...)
|
||||||
} else if *wm == "sway" {
|
} else if *wm == "sway" {
|
||||||
cmd = exec.Command("swaymsg", "exec", strings.Join(elements, " "))
|
cmd = exec.Command("swaymsg", "exec", strings.Join(elements, " "))
|
||||||
} else if *wm == "hyprland" {
|
} else if *wm == "hyprland" || *wm == "Hyprland" {
|
||||||
cmd = exec.Command("hyprctl", "dispatch", "exec", strings.Join(elements, " "))
|
cmd = exec.Command("hyprctl", "dispatch", "exec", strings.Join(elements, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// set env variables
|
msg := fmt.Sprintf("command: %q; args: %q\n", cmd.Args[0], cmd.Args[1:])
|
||||||
if len(envVars) > 0 {
|
|
||||||
cmd.Env = os.Environ()
|
|
||||||
cmd.Env = append(cmd.Env, envVars...)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := fmt.Sprintf("env vars: %s; command: '%s'; args: %s\n", envVars, cmd.Args[0], cmd.Args[1:])
|
|
||||||
log.Info(msg)
|
log.Info(msg)
|
||||||
|
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
|||||||
Reference in New Issue
Block a user