mirror of
https://codeberg.org/scip/swaycycle.git
synced 2025-12-16 20:11:02 +01:00
Compare commits
1 Commits
v0.3.1
...
enhancedeb
| Author | SHA1 | Date | |
|---|---|---|---|
| 640b0533b8 |
17
main.go
17
main.go
@@ -57,6 +57,7 @@ var (
|
|||||||
CurrentWorkspace = ""
|
CurrentWorkspace = ""
|
||||||
Debug = false
|
Debug = false
|
||||||
Dumptree = false
|
Dumptree = false
|
||||||
|
Dumpvisibles = false
|
||||||
Version = false
|
Version = false
|
||||||
Verbose = false
|
Verbose = false
|
||||||
Notswitch = false
|
Notswitch = false
|
||||||
@@ -72,6 +73,7 @@ Options:
|
|||||||
-n, --no-switch do not switch windows
|
-n, --no-switch do not switch windows
|
||||||
-d, --debug enable debugging
|
-d, --debug enable debugging
|
||||||
-D, --dump dump the sway tree (needs -d as well)
|
-D, --dump dump the sway tree (needs -d as well)
|
||||||
|
--dump-visibles dump a list of visible windows on current workspace (needs -d)
|
||||||
-l, --logfile string write output to logfile
|
-l, --logfile string write output to logfile
|
||||||
-v, --version show program version
|
-v, --version show program version
|
||||||
|
|
||||||
@@ -82,6 +84,7 @@ Licensed under the terms of the GNU GPL version 3.
|
|||||||
func main() {
|
func main() {
|
||||||
flag.BoolVarP(&Debug, "debug", "d", false, "enable debugging")
|
flag.BoolVarP(&Debug, "debug", "d", false, "enable debugging")
|
||||||
flag.BoolVarP(&Dumptree, "dump", "D", false, "dump the sway tree (needs -d as well)")
|
flag.BoolVarP(&Dumptree, "dump", "D", false, "dump the sway tree (needs -d as well)")
|
||||||
|
flag.BoolVarP(&Dumpvisibles, "dump-visibles", "", false, "dump a list of visible windows on current workspace (needs -d)")
|
||||||
flag.BoolVarP(&Notswitch, "no-switch", "n", false, "do not switch windows")
|
flag.BoolVarP(&Notswitch, "no-switch", "n", false, "do not switch windows")
|
||||||
flag.BoolVarP(&Version, "version", "v", false, "show program version")
|
flag.BoolVarP(&Version, "version", "v", false, "show program version")
|
||||||
flag.BoolVarP(&Showhelp, "help", "h", Showhelp, "show help")
|
flag.BoolVarP(&Showhelp, "help", "h", Showhelp, "show help")
|
||||||
@@ -162,7 +165,9 @@ func processJSON(sway *i3ipc.Node) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Debug("processed visible windows", "visibles", Visibles)
|
if Dumpvisibles {
|
||||||
|
dumpVisibles()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -234,6 +239,16 @@ func recurseNodes(nodes []*i3ipc.Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dumpVisibles() {
|
||||||
|
windows := make([]string, len(Visibles))
|
||||||
|
|
||||||
|
for idx, node := range Visibles {
|
||||||
|
windows[idx] = fmt.Sprintf("id: %02d, focus: %5t, name: %s", node.Id, node.Focused, node.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Debug("visible windows on current workspace", "visibles", windows)
|
||||||
|
}
|
||||||
|
|
||||||
// we use line wise logging, unless debugging is enabled
|
// we use line wise logging, unless debugging is enabled
|
||||||
func setupLogging(output io.Writer) {
|
func setupLogging(output io.Writer) {
|
||||||
logLevel := &slog.LevelVar{}
|
logLevel := &slog.LevelVar{}
|
||||||
|
|||||||
Reference in New Issue
Block a user