https://github.com/1995parham/gosimac
Fetch the wallpaper from Bing, Unsplash, etc.
https://github.com/1995parham/gosimac
bing unsplash wallpaper
Last synced: 7 months ago
JSON representation
Fetch the wallpaper from Bing, Unsplash, etc.
- Host: GitHub
- URL: https://github.com/1995parham/gosimac
- Owner: 1995parham
- License: gpl-2.0
- Created: 2015-11-24T22:59:26.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T13:36:43.000Z (7 months ago)
- Last Synced: 2025-04-12T19:53:22.928Z (7 months ago)
- Topics: bing, unsplash, wallpaper
- Language: Go
- Homepage:
- Size: 335 KB
- Stars: 31
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go Si Mac
## Introduction
_GoSiMac_ downloads Bing's daily wallpapers, Unsplash's random images, etc. for you to have a beautiful wallpaper on your desktop whenever you want.
Personally, I wrote this to have fun and help one of my friends who are not among us right now. :disappointed:
## Usage
```bash
gosimac rev-4cbe101-dirty
Fetch the wallpaper from Bings, Unsplash...
Usage:
GoSiMac [command]
Available Commands:
bing fetches images from https://bing.com
completion Generate the autocompletion script for the specified shell
help Help about any command
unsplash fetches images from https://unsplash.org
Flags:
-h, --help help for GoSiMac
-p, --path string A path to where photos are stored (default "/home/parham/Pictures/GoSiMac")
Use "GoSiMac [command] --help" for more information about a command.
```
As an example, the following command downloads 10 images from unsplash while using Tehran as a search query.
Please note that the proxy setup is related to Iranian sanctions and you may not need to setup any proxy
to use gosimac.
```bash
export http_proxy="http://127.0.0.1:1080"
export https_proxy="http://127.0.0.1:1080"
gosimac u -q Tehran -n 10
```
```powershell
set http_proxy "http://127.0.0.1:1080"
set https_proxy "http://127.0.0.1:1080"
$env:HTTP_PROXY = "http://127.0.0.1:1080"
$env:HTTPS_PROXY = "http://127.0.0.1:1080"
gosimac u -q Tehran -n 10
```
By default, _gosimac_ stores images in `$XDG_PICTURES_DIR/GoSiMac (e.g. $HOME/Pictures/GoSiMac)`.
## Contribution
For adding new source you only need to create a new sub-command in `cmd` package
and then calling your new source with provided `path`. Also for saving images
you can use the following helper function:
```go
func (u *Unsplash) Store(name string, content io.ReadCloser) {
path := path.Join(
u.Path,
fmt.Sprintf("%s-%s.jpg", u.Prefix, name),
)
if _, err := os.Stat(path); err == nil {
pterm.Warning.Printf("%s is already exists\n", path)
return
}
file, err := os.Create(path)
if err != nil {
pterm.Error.Printf("os.Create: %v\n", err)
return
}
bytes, err := io.Copy(file, content)
if err != nil {
pterm.Error.Printf("io.Copy (%d bytes): %v\n", bytes, err)
}
if err := file.Close(); err != nil {
pterm.Error.Printf("(*os.File).Close: %v", err)
}
if err := content.Close(); err != nil {
pterm.Error.Printf("(*io.ReadCloser).Close: %v", err)
}
}
```