refactoring: move logic in different files
This commit is contained in:
parent
8e5d3c7907
commit
098b04f5a5
5 changed files with 108 additions and 49 deletions
37
wallpaper.go
Normal file
37
wallpaper.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.i3wm.org/i3"
|
||||
)
|
||||
|
||||
func GetWorkspaceWallpaper(workspace string, config Config) string {
|
||||
file := config.Default
|
||||
workspaceFile := config.Workspaces[workspace]
|
||||
|
||||
if workspaceFile != "" {
|
||||
file = workspaceFile
|
||||
}
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
func GetOutputsWallpapers(config Config) ([]string, error) {
|
||||
files := []string{}
|
||||
outputs, err := i3.GetOutputs()
|
||||
|
||||
if err != nil {
|
||||
return files, err
|
||||
}
|
||||
|
||||
for _, output := range outputs {
|
||||
if output.CurrentWorkspace != "" {
|
||||
file := GetWorkspaceWallpaper(output.CurrentWorkspace, config)
|
||||
|
||||
if file != "" {
|
||||
files = append(files, file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue