This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vivwal
executable file
·57 lines (52 loc) · 1.66 KB
/
vivwal
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
57
#!/bin/env bash
# Sets Vivaldi's theme colors to those generated by Wal.
# Source: https://forum.vivaldi.net/topic/34521/linux-changing-theme-via-command-line/22?_=1597433612704
# Author: Vivaldi Forum user Wismut
logfile=~/.log/vivwal.log
text_color="#eeeeee"
if [[ "$1" && "$1" == "-l" ]]; then
text_color="#111111"
fi
# Source Wal colors (replace this path with the path where the colors generated by wal are stored)
source ~/.cache/wal/colors.sh
# testing if vivaldi is running
PROCESS1=vivaldi
PROCESS2=crconsole
PIDS_Vivaldi=`ps cax | grep $PROCESS1 | grep -o '^[ ]*[0-9]*'`
PIDS_crconsole=`ps cax | grep $PROCESS2 | grep -o '^[ ]*[0-9]*'`
if [ -z "$PIDS_Vivaldi" ]; then
# Vivaldi is not running
if [ -z "$PIDS_crconsole" ]; then
echo "All is fine. Neither Vivaldi nor crconsole are running." 1>&2
else
# kill crconsole
pkill -f "node /usr/bin/crconsole"
fi
else
# Vivaldi is running
# let's start using crconsole
# find all open tabs
tablist=$(
echo .tabs | crconsole &
sleep 1
pkill -f "node /usr/bin/crconsole"
)
# read each tab
while read -r line; do
echo "... $line ..."
# find /browser.html tab
if [[ $line == *"/browser.html"* ]]; then
tabnumber=$(echo "$line" | grep -o '[0-9]\+')
# change Vivaldi accent background colors
var=$(
(echo ".switch $tabnumber"; sleep 1; echo "chrome.storage.local.set({'BROWSER_COLOR_BG':'$background', 'BROWSER_COLOR_FG':'$text_color', 'BROWSER_COLOR_ACCENT_BG':'$color5', 'BROWSER_COLOR_HIGHLIGHT_BG':'$color1'})") | crconsole &
sleep 1
pkill -f "node /usr/bin/crconsole"
)
echo "$var" > $logfile
fi
done <<< "$tablist"
sleep 1
pkill -f "node /usr/bin/crconsole"
fi
exit