aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/wally
blob: 91ab90efcaced80b4d7e7d4a23ba570b74cec03d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

# A script to generate a theme for my system (auto-rice)
# Dependencies: pywal, feh, xdotool
# By David Penkowoj, 2022-01-31

# Usage: wally {path to image} [backend] [saturation value]

backend="colorz"
saturation="0.5"
wallpaperDir="$HOME/images/wallpapers"
cachedWallpaperFile="$HOME/.config/wallpaper"

setTheme() {
  echo "Overwriting previous color backup with current colors."
  mv "$HOME/.cache/wal/colors" "$HOME/.cache/wal/oldcolors"
  echo "Generating new color scheme."
  wal -i "$1" -q -b "#1a1a1a" --saturate "$saturation"
  echo "Caching wallpaper."
  cp "$1" "$cachedWallpaperFile"
  echo "Setting wallpaper."
  feh --bg-fill "$cachedWallpaperFile"
  echo "Updating various software with rica."
  rica
  echo "Refreshing window manager."
  xdotool key Super_L+r
}

if [[ -n "$3" ]]; then
  echo "Got saturation value '$3'."
  saturation="$3"
else 
  echo "Did not recieve saturation value as third argument"
fi

if [[ -n "$2" ]]; then
  echo "Got backend value '$2'."
  backend="$2"
else 
  echo "Did not recieve backend value as second argument"
fi

if [[ -f "$1" ]]; then
  echo "Image found in relative directory."
  setTheme "$1"
else
  echo "File not found, searching wallpaper directory."

  if [[ -f "$wallpaperDir/$1" ]]; then
    echo "Image found in wallpaper directory."
    setTheme "$wallpaperDir/$1"
  else
    echo "No image found."
  fi
fi