From 0157a6a002add0f1cfc1ae673c6df0415b2a0e8e Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 31 Jul 2024 23:30:16 +0200 Subject: [PATCH 01/17] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef9e6e2..c9e24d4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ +_Thanks [AZProductions](https://github.com/AZProductions/AbstractCollection/)!_ + ## 📗 How to install the project ### Dependencies From 70fe7c72ce8e457eeafebca1a0464b9919c012f3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 20:08:56 +0200 Subject: [PATCH 02/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9e24d4..77d9caa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🖥️ i3 wallpaper manager -**i3 wallpaper manager** is a command-line tool designed to change the wallpaper depending of active workspaces on [i3](https://i3wm.org/). +**i3 wallpaper manager** is a command-line tool designed to change the wallpaper depending of active workspaces on [i3](https://i3wm.org/). This tool works on one or multiple screens. From d11d8c7f87bed9ccb7c90162c2aab6821c4109c1 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:47:26 +0200 Subject: [PATCH 03/17] add callback option --- README.md | 16 +++++++++++++++- callback.go | 19 +++++++++++++++++++ config.go | 1 + config.yaml.example | 1 + wallpaper.go | 21 ++++++++++++++++----- 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 callback.go diff --git a/README.md b/README.md index 77d9caa..d04fb6c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ workspaces: "Name of the workspace 3": /home/alice/wallpapers/3.jpg ``` -Next, you simply need to run `i3-wallpaper-manager` while specify the path to the configuration file. +Next, you simply need to run `i3-wallpaper-manager` and specify the path to the configuration file. ```bash DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml @@ -48,3 +48,17 @@ To run it when i3 starts, add this to your i3 configuration: ```bash exec_always DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml ``` + +If you wish to use a program other than `feh`, set the `callback` parameter by specifying the path to your script. + +``` +#!/bin/sh + +SCREEN_1="$1" +WALLPAPER_1="$2" + +SCREEN_2="$3" +WALLPAPER_2="$4" + +# ... +``` diff --git a/callback.go b/callback.go new file mode 100644 index 0000000..63a9fc0 --- /dev/null +++ b/callback.go @@ -0,0 +1,19 @@ +package main + +import ( + "os" + "os/exec" +) + +func CallbackUpdateWallpapers(callback string, files, screens []string) (*exec.Cmd, error) { + args := []string{} + + for key, file := range files { + args = append(args, screens[key], file) + } + + cmd := exec.Command(callback, args...) + cmd.Env = os.Environ() + + return cmd, cmd.Run() +} diff --git a/config.go b/config.go index 9e657cf..e90166f 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,7 @@ import ( type Config struct { Default string `yaml:"default"` + Callback string `yaml:"callback"` Workspaces map[string]string `yaml:"workspaces"` } diff --git a/config.yaml.example b/config.yaml.example index 5e50253..0cf69eb 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -3,3 +3,4 @@ workspaces: "Name of the workspace 1": /home/alice/wallpapers/1.jpg "Name of the workspace 2": /home/alice/wallpapers/2.jpg "Name of the workspace 3": /home/alice/wallpapers/3.jpg +# callback: /path/to/custom.sh diff --git a/wallpaper.go b/wallpaper.go index bbef976..016aa3a 100644 --- a/wallpaper.go +++ b/wallpaper.go @@ -2,6 +2,7 @@ package main import ( "log" + "os/exec" "go.i3wm.org/i3" ) @@ -17,11 +18,13 @@ func GetWorkspaceWallpaper(workspace string, config Config) string { return file } -func GetOutputsWallpapers(config Config) ([]string, error) { +func GetOutputsWallpapers(config Config) ([]string, []string, error) { files := []string{} + screens := []string{} outputs, err := i3.GetOutputs() + if err != nil { - return files, err + return files, screens, err } for _, output := range outputs { @@ -30,21 +33,29 @@ func GetOutputsWallpapers(config Config) ([]string, error) { if file != "" { files = append(files, file) + screens = append(screens, output.Name) } } } - return files, nil + return files, screens, nil } func UpdateWallapers(config Config) { - files, err := GetOutputsWallpapers(config) + files, screens, err := GetOutputsWallpapers(config) + if err != nil { log.Printf("[ERROR] %s", err.Error()) return } - cmd, err := FehUpdateWallpapers(files) + var cmd *exec.Cmd + + if config.Callback == "" { + cmd, err = FehUpdateWallpapers(files) + } else { + cmd, err = CallbackUpdateWallpapers(config.Callback, files, screens) + } if err != nil { log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error()) From 7dffb515a6c7d056cfcbfca59c886cdfba3710fa Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:47:54 +0200 Subject: [PATCH 04/17] apply linter --- wallpaper.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/wallpaper.go b/wallpaper.go index 016aa3a..1919652 100644 --- a/wallpaper.go +++ b/wallpaper.go @@ -22,7 +22,6 @@ func GetOutputsWallpapers(config Config) ([]string, []string, error) { files := []string{} screens := []string{} outputs, err := i3.GetOutputs() - if err != nil { return files, screens, err } @@ -43,7 +42,6 @@ func GetOutputsWallpapers(config Config) ([]string, []string, error) { func UpdateWallapers(config Config) { files, screens, err := GetOutputsWallpapers(config) - if err != nil { log.Printf("[ERROR] %s", err.Error()) return From b640603c1ea128721d44932d1db5df11dd9ccf69 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:48:30 +0200 Subject: [PATCH 05/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d04fb6c..1c622e4 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ exec_always DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml If you wish to use a program other than `feh`, set the `callback` parameter by specifying the path to your script. -``` +```bash #!/bin/sh SCREEN_1="$1" From 9de5f7bab9a418d033f17888971cdf32d2afed54 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:49:07 +0200 Subject: [PATCH 06/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c622e4..67171a8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ _Thanks [AZProductions](https://github.com/AZProductions/AbstractCollection/)!_ ### Dependencies -- [Feh](https://feh.finalrewind.org/) +- [Feh](https://feh.finalrewind.org/) (by default) ### Pre-compiled versions From 540156b7d97eded187a2997b9241045c8b10ce5a Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:50:30 +0200 Subject: [PATCH 07/17] update readme --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 67171a8..a2386cc 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,13 @@ exec_always DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml If you wish to use a program other than `feh`, set the `callback` parameter by specifying the path to your script. +```yaml +callback: /path/to/custom.sh +``` + ```bash #!/bin/sh +# /path/to/custom.sh SCREEN_1="$1" WALLPAPER_1="$2" @@ -60,5 +65,5 @@ WALLPAPER_1="$2" SCREEN_2="$3" WALLPAPER_2="$4" -# ... +... ``` From 7320d1ea6b89c9ee148ec9b8562122ec4cbab095 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:50:54 +0200 Subject: [PATCH 08/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2386cc..6a38d38 100644 --- a/README.md +++ b/README.md @@ -65,5 +65,5 @@ WALLPAPER_1="$2" SCREEN_2="$3" WALLPAPER_2="$4" -... +# Do stuff... ``` From 71325c5ffcc2d668a44694009e30de049f8d4b44 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:53:15 +0200 Subject: [PATCH 09/17] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5287b0b..df5d447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ [Unreleased] +## v1.2.0 +### Added +- Add `callback` option + ## v1.1.1 ### Fixed - Update wallpapers on start From 45a3da8a005836be56c462cad62d32335ef0e199 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 1 Aug 2024 22:59:12 +0200 Subject: [PATCH 10/17] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a38d38..6161d79 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ WALLPAPER_1="$2" SCREEN_2="$3" WALLPAPER_2="$4" +# etc. # Do stuff... ``` From 34ddaa18027a17aca8714de031fbd28603b9e0e5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 2 Aug 2024 22:57:13 +0200 Subject: [PATCH 11/17] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6161d79..41f528b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# 🖥️ i3 wallpaper manager +# 🖥️ i3 Wallpaper Manager -**i3 wallpaper manager** is a command-line tool designed to change the wallpaper depending of active workspaces on [i3](https://i3wm.org/). This tool works on one or multiple screens. +**i3 Wallpaper Manager** is a command-line tool designed to change the wallpaper depending of active workspaces on [i3](https://i3wm.org/). This tool works on one or multiple screens. From f8b846018b062c83dbea18d47b9e6d577e1d342f Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 4 Aug 2024 17:59:03 +0200 Subject: [PATCH 12/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41f528b..4bfe0b1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml To run it when i3 starts, add this to your i3 configuration: ```bash -exec_always DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml +exec --no-startup-id DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml ``` If you wish to use a program other than `feh`, set the `callback` parameter by specifying the path to your script. From 3e3f4445a4e9d1289e470d8ca95dd12729fc9a22 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Aug 2024 19:16:00 +0200 Subject: [PATCH 13/17] fix #1: add cache of latest command to not run wallpaper update when it's already up to date --- callback.go | 4 ++-- feh.go | 4 ++-- main.go | 7 +++++-- wallpaper.go | 14 +++++++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/callback.go b/callback.go index 63a9fc0..270c942 100644 --- a/callback.go +++ b/callback.go @@ -5,7 +5,7 @@ import ( "os/exec" ) -func CallbackUpdateWallpapers(callback string, files, screens []string) (*exec.Cmd, error) { +func CallbackUpdateWallpapers(callback string, files, screens []string) *exec.Cmd { args := []string{} for key, file := range files { @@ -15,5 +15,5 @@ func CallbackUpdateWallpapers(callback string, files, screens []string) (*exec.C cmd := exec.Command(callback, args...) cmd.Env = os.Environ() - return cmd, cmd.Run() + return cmd } diff --git a/feh.go b/feh.go index 4884960..9e8b562 100644 --- a/feh.go +++ b/feh.go @@ -5,7 +5,7 @@ import ( "os/exec" ) -func FehUpdateWallpapers(files []string) (*exec.Cmd, error) { +func FehUpdateWallpapers(files []string) *exec.Cmd { args := []string{} for _, file := range files { @@ -15,5 +15,5 @@ func FehUpdateWallpapers(files []string) (*exec.Cmd, error) { cmd := exec.Command("feh", args...) cmd.Env = os.Environ() - return cmd, cmd.Run() + return cmd } diff --git a/main.go b/main.go index ad7c01a..81c8d3e 100644 --- a/main.go +++ b/main.go @@ -16,18 +16,21 @@ func main() { } config, err := LoadConfiguration(os.Args[1]) + if err != nil { log.Printf("[ERROR] %s", err.Error()) os.Exit(1) } - UpdateWallapers(config) + var lastCommand string + + UpdateWallapers(config, &lastCommand) for recv.Next() { event := recv.Event().(*i3.WorkspaceEvent) if event.Change == "focus" { - UpdateWallapers(config) + UpdateWallapers(config, &lastCommand) } } } diff --git a/wallpaper.go b/wallpaper.go index 1919652..bec24d4 100644 --- a/wallpaper.go +++ b/wallpaper.go @@ -40,7 +40,7 @@ func GetOutputsWallpapers(config Config) ([]string, []string, error) { return files, screens, nil } -func UpdateWallapers(config Config) { +func UpdateWallapers(config Config, lastCommand *string) { files, screens, err := GetOutputsWallpapers(config) if err != nil { log.Printf("[ERROR] %s", err.Error()) @@ -50,14 +50,22 @@ func UpdateWallapers(config Config) { var cmd *exec.Cmd if config.Callback == "" { - cmd, err = FehUpdateWallpapers(files) + cmd = FehUpdateWallpapers(files) } else { - cmd, err = CallbackUpdateWallpapers(config.Callback, files, screens) + cmd = CallbackUpdateWallpapers(config.Callback, files, screens) } + if cmd.String() == *lastCommand { + log.Printf("[INFO] wallapaper(s) already up to date") + return + } + + err = cmd.Run() + if err != nil { log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error()) } else { log.Printf("[SUCCESS] cmd=%s", cmd.String()) + *lastCommand = cmd.String() } } From aa10117aefa659f21b6ae518de8a9d8f35712c8b Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Aug 2024 19:16:51 +0200 Subject: [PATCH 14/17] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df5d447..e592102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ [Unreleased] +## v1.2.1 +### Fixed +- Fix #1: add cache of latest command to not run wallpaper update when it's already up to date + ## v1.2.0 ### Added - Add `callback` option From 81038ba96d05bad7fab8131d58d02988cd9f35fe Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Aug 2024 19:20:26 +0200 Subject: [PATCH 15/17] add debian packaging deb-recommends --- .fpm | 1 + 1 file changed, 1 insertion(+) diff --git a/.fpm b/.fpm index 747df4e..247b8cf 100644 --- a/.fpm +++ b/.fpm @@ -3,4 +3,5 @@ --license agpl3 --description "Wallpaper manager for i3" --url "https://gitnet.fr/deblan/i3-wallpaper-manager" +--deb-recommends "feh" --maintainer "Simon Vieille " From e717e15f9eaf3e5e4f557256349a5bdcbbb0d864 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Aug 2024 19:21:57 +0200 Subject: [PATCH 16/17] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e592102..7aab162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ [Unreleased] ## v1.2.1 +### Added +- Add debian packaging deb-recommends ### Fixed - Fix #1: add cache of latest command to not run wallpaper update when it's already up to date From 0548409184c33159f253c565bccc269c1bc915a7 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 11 Aug 2024 19:35:19 +0200 Subject: [PATCH 17/17] add gitea templates --- .gitea/issue_template/FEATURE_TEMPLATE.yml | 34 +++++++++++ .gitea/issue_template/ISSUE_TEMPLATE.yml | 63 +++++++++++++++++++++ .gitea/issue_template/QUESTION_TEMPLATE.yml | 26 +++++++++ .gitea/issue_template/config.yml | 8 +++ 4 files changed, 131 insertions(+) create mode 100644 .gitea/issue_template/FEATURE_TEMPLATE.yml create mode 100644 .gitea/issue_template/ISSUE_TEMPLATE.yml create mode 100644 .gitea/issue_template/QUESTION_TEMPLATE.yml create mode 100644 .gitea/issue_template/config.yml diff --git a/.gitea/issue_template/FEATURE_TEMPLATE.yml b/.gitea/issue_template/FEATURE_TEMPLATE.yml new file mode 100644 index 0000000..3d687c5 --- /dev/null +++ b/.gitea/issue_template/FEATURE_TEMPLATE.yml @@ -0,0 +1,34 @@ +name: New feature +about: Use this template if you want to request a feature +title: "[FEATURE] " +labels: + - Kind/Enhancement +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! + + - type: textarea + id: description + attributes: + label: Description + description: Describe the feature. + validations: + required: true + + - type: textarea + id: benefits + attributes: + label: Benefits + description: Describe the benefits of this feature. + validations: + required: true + + - type: textarea + id: extra + attributes: + label: More informations + description: If you want to share more things, this is here! + validations: + required: false diff --git a/.gitea/issue_template/ISSUE_TEMPLATE.yml b/.gitea/issue_template/ISSUE_TEMPLATE.yml new file mode 100644 index 0000000..0a703fd --- /dev/null +++ b/.gitea/issue_template/ISSUE_TEMPLATE.yml @@ -0,0 +1,63 @@ +name: New issue +about: Use this template if you have a bug +title: "[Bug] " +labels: + - Kind/Bug +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + - type: textarea + id: environment + attributes: + label: Environment + value: | + * i3 wallpaper manager version: + * i3-wm version: + * Operating system and version: + validations: + required: true + + - type: textarea + id: configuration + attributes: + label: Configuration + value: | + ``` + ``` + validations: + required: false + + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: How reproduce the bug? + validations: + required: false + + - type: textarea + id: resuts + attributes: + label: Observed Results + description: What happened? + validations: + required: false + + - type: textarea + id: expected + attributes: + label: Expected Results + description: What should happen? + validations: + required: false + + - type: textarea + id: extra + attributes: + label: More informations + description: If you want to share more things, this is here! + validations: + required: false diff --git a/.gitea/issue_template/QUESTION_TEMPLATE.yml b/.gitea/issue_template/QUESTION_TEMPLATE.yml new file mode 100644 index 0000000..30fd73c --- /dev/null +++ b/.gitea/issue_template/QUESTION_TEMPLATE.yml @@ -0,0 +1,26 @@ +name: New question +about: Use this template when you don't know how to do something +title: "[Question] " +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill information. + + - type: textarea + id: environment + attributes: + label: Environment + value: | + * i3 wallpaper manager version: + * i3-wm version: + * Operating system and version: + validations: + required: true + + - type: textarea + id: question + attributes: + label: Question + validations: + required: true diff --git a/.gitea/issue_template/config.yml b/.gitea/issue_template/config.yml new file mode 100644 index 0000000..d3fdf27 --- /dev/null +++ b/.gitea/issue_template/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Documentation + url: https://gitnet.fr/deblan/i3-wallpaper-manager + about: Official documentation web site + - name: Ask a question in our Matrix room + about: If you prefer a chat-like conversation or in need for quick help, this might be an alternative to opening an issue. + url: https://matrix.to/#/!QDcaVhvLZlhptPkGVi:neutralnetwork.org?via=neutralnetwork.org