Compare commits

..

23 commits

Author SHA1 Message Date
0548409184
add gitea templates
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-11 19:35:19 +02:00
e717e15f9e
update changelog
All checks were successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-08-11 19:21:57 +02:00
81038ba96d
add debian packaging deb-recommends
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-08-11 19:20:26 +02:00
aa10117aef
update changelog
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-11 19:16:51 +02:00
3e3f4445a4
fix #1: add cache of latest command to not run wallpaper update when it's already up to date
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-11 19:16:00 +02:00
f8b846018b
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-04 17:59:03 +02:00
34ddaa1802
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-02 22:57:13 +02:00
45a3da8a00
update readme
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-08-01 22:59:12 +02:00
71325c5ffc
update changelog
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful
2024-08-01 22:53:15 +02:00
7320d1ea6b
update readme
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-08-01 22:50:54 +02:00
540156b7d9
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-01 22:50:30 +02:00
9de5f7bab9
update readme 2024-08-01 22:49:07 +02:00
b640603c1e
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-01 22:48:30 +02:00
8c0bc5c710 Merge branch 'feature/callback' into develop
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-01 22:48:05 +02:00
7dffb515a6
apply linter 2024-08-01 22:47:54 +02:00
d11d8c7f87
add callback option 2024-08-01 22:47:26 +02:00
70fe7c72ce
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-08-01 20:08:56 +02:00
0157a6a002
update readme
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-07-31 23:30:16 +02:00
e229ae1440
update wallpapers on start
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful
2024-07-31 23:13:59 +02:00
1a94e88eff
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-07-31 22:58:23 +02:00
6ecfaa194a
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-07-31 22:56:53 +02:00
4c42d27e65
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-07-31 22:56:33 +02:00
530ecf4689
update readme
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
2024-07-31 22:55:27 +02:00
14 changed files with 242 additions and 31 deletions

1
.fpm
View file

@ -3,4 +3,5 @@
--license agpl3 --license agpl3
--description "Wallpaper manager for i3" --description "Wallpaper manager for i3"
--url "https://gitnet.fr/deblan/i3-wallpaper-manager" --url "https://gitnet.fr/deblan/i3-wallpaper-manager"
--deb-recommends "feh"
--maintainer "Simon Vieille <contact+i3wallpapermanager@deblan.fr>" --maintainer "Simon Vieille <contact+i3wallpapermanager@deblan.fr>"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,19 @@
[Unreleased] [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
## v1.2.0
### Added
- Add `callback` option
## v1.1.1
### Fixed
- Update wallpapers on start
## v1.1.0 ## v1.1.0
### Changed ### Changed
- Refactoring - Refactoring

View file

@ -1,12 +1,16 @@
# 🖥️ 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/). **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.
<video controls src="https://deblan.gitnet.page/i3-wallpaper-manager/demo.webm" type="video/webm" width="50%"></video>
_Thanks [AZProductions](https://github.com/AZProductions/AbstractCollection/)!_
## 📗 How to install the project ## 📗 How to install the project
### Dependencies ### Dependencies
- [Feh](https://feh.finalrewind.org/) - [Feh](https://feh.finalrewind.org/) (by default)
### Pre-compiled versions ### Pre-compiled versions
@ -33,7 +37,7 @@ workspaces:
"Name of the workspace 3": /home/alice/wallpapers/3.jpg "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 ```bash
DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml
@ -42,5 +46,25 @@ DISPLAY=:0 i3-wallpaper-manager /path/to/config.yaml
To run it when i3 starts, add this to your i3 configuration: To run it when i3 starts, add this to your i3 configuration:
```bash ```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.
```yaml
callback: /path/to/custom.sh
```
```bash
#!/bin/sh
# /path/to/custom.sh
SCREEN_1="$1"
WALLPAPER_1="$2"
SCREEN_2="$3"
WALLPAPER_2="$4"
# etc.
# Do stuff...
``` ```

19
callback.go Normal file
View file

@ -0,0 +1,19 @@
package main
import (
"os"
"os/exec"
)
func CallbackUpdateWallpapers(callback string, files, screens []string) *exec.Cmd {
args := []string{}
for key, file := range files {
args = append(args, screens[key], file)
}
cmd := exec.Command(callback, args...)
cmd.Env = os.Environ()
return cmd
}

View file

@ -8,6 +8,7 @@ import (
type Config struct { type Config struct {
Default string `yaml:"default"` Default string `yaml:"default"`
Callback string `yaml:"callback"`
Workspaces map[string]string `yaml:"workspaces"` Workspaces map[string]string `yaml:"workspaces"`
} }

View file

@ -3,3 +3,4 @@ workspaces:
"Name of the workspace 1": /home/alice/wallpapers/1.jpg "Name of the workspace 1": /home/alice/wallpapers/1.jpg
"Name of the workspace 2": /home/alice/wallpapers/2.jpg "Name of the workspace 2": /home/alice/wallpapers/2.jpg
"Name of the workspace 3": /home/alice/wallpapers/3.jpg "Name of the workspace 3": /home/alice/wallpapers/3.jpg
# callback: /path/to/custom.sh

View file

@ -1,14 +0,0 @@
package main
import (
"os/exec"
)
func HandleFocusEvent(config Config) (*exec.Cmd, error) {
files, err := GetOutputsWallpapers(config)
if err != nil {
return nil, err
}
return FehUpdateWallpapers(files)
}

4
feh.go
View file

@ -5,7 +5,7 @@ import (
"os/exec" "os/exec"
) )
func FehUpdateWallpapers(files []string) (*exec.Cmd, error) { func FehUpdateWallpapers(files []string) *exec.Cmd {
args := []string{} args := []string{}
for _, file := range files { for _, file := range files {
@ -15,5 +15,5 @@ func FehUpdateWallpapers(files []string) (*exec.Cmd, error) {
cmd := exec.Command("feh", args...) cmd := exec.Command("feh", args...)
cmd.Env = os.Environ() cmd.Env = os.Environ()
return cmd, cmd.Run() return cmd
} }

13
main.go
View file

@ -16,22 +16,21 @@ func main() {
} }
config, err := LoadConfiguration(os.Args[1]) config, err := LoadConfiguration(os.Args[1])
if err != nil { if err != nil {
log.Printf("[ERROR] %s", err.Error()) log.Printf("[ERROR] %s", err.Error())
os.Exit(1) os.Exit(1)
} }
var lastCommand string
UpdateWallapers(config, &lastCommand)
for recv.Next() { for recv.Next() {
event := recv.Event().(*i3.WorkspaceEvent) event := recv.Event().(*i3.WorkspaceEvent)
if event.Change == "focus" { if event.Change == "focus" {
cmd, err := HandleFocusEvent(config) UpdateWallapers(config, &lastCommand)
if err != nil {
log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error())
} else {
log.Printf("[SUCCESS] cmd=%s", cmd.String())
}
} }
} }
} }

View file

@ -1,6 +1,9 @@
package main package main
import ( import (
"log"
"os/exec"
"go.i3wm.org/i3" "go.i3wm.org/i3"
) )
@ -15,11 +18,12 @@ func GetWorkspaceWallpaper(workspace string, config Config) string {
return file return file
} }
func GetOutputsWallpapers(config Config) ([]string, error) { func GetOutputsWallpapers(config Config) ([]string, []string, error) {
files := []string{} files := []string{}
screens := []string{}
outputs, err := i3.GetOutputs() outputs, err := i3.GetOutputs()
if err != nil { if err != nil {
return files, err return files, screens, err
} }
for _, output := range outputs { for _, output := range outputs {
@ -28,9 +32,40 @@ func GetOutputsWallpapers(config Config) ([]string, error) {
if file != "" { if file != "" {
files = append(files, file) files = append(files, file)
screens = append(screens, output.Name)
} }
} }
} }
return files, nil return files, screens, nil
}
func UpdateWallapers(config Config, lastCommand *string) {
files, screens, err := GetOutputsWallpapers(config)
if err != nil {
log.Printf("[ERROR] %s", err.Error())
return
}
var cmd *exec.Cmd
if config.Callback == "" {
cmd = FehUpdateWallpapers(files)
} else {
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()
}
} }