-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.sh
executable file
·165 lines (143 loc) · 4.66 KB
/
plugin.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# File : make.sh
# Brief : Compiles, installs, and uninstalls the SD Prompt Viewer plugin
# Author : Martin Rizzo | <martinrizzo@gmail.com>
# Date : Mar 25, 2023
# Repo : https://github.com/martin-rizzo/SDPromptViewer
# License : MIT
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Stable Diffusion Prompt Viewer
# A plugin for "Eye of GNOME" that displays SD embedded prompts.
#
# Copyright (c) 2023 Martin Rizzo
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
SCRIPT_NAME=${BASH_SOURCE[0]##*/}
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_HELP="
Usage: ./$SCRIPT_NAME [TARGET]
This script compiles, executes, installs, and uninstalls
the Stable Diffusion Prompt Viewer plugin for Eye of GNOME.
Available targets:
build Compiles the plugin.
run Runs Eye of GNOME with the plugin installed.
clean Removes files generated by compilation.
install Installs the plugin into Eye of GNOME.
remove Uninstalls the plugin from Eye of GNOME.
Example:
./$SCRIPT_NAME install # Installs the plugin.
"
# IMPORTANT:
# Directory where test images are located. These images are used
# when running './plugin.sh run' to test the plugin functionality.
TEST_IMAGES_DIR="$HOME/Extra/Test"
# Directory where the GSettings schemas are stored
GIO_SCHEMAS_DIR="$HOME/.local/share/glib-2.0/schemas"
# Initialize script status to 0 (success)
SCRIPT_STATUS=0
#--------------------------------- TARGETS ---------------------------------#
build() {
echo "Executing build command..."
make
return $?
}
run() {
echo "Executing run command..."
make install || return 1
if [ -e "$TEST_IMAGES_DIR" ]; then
EOG_DEBUG_PLUGINS='true' GOBJECT_DEBUG='instance-count' eog "$TEST_IMAGES_DIR" & disown
else
EOG_DEBUG_PLUGINS='true' GOBJECT_DEBUG='instance-count' eog &disown
fi
return 0
}
clean() {
echo "Executing clean command..."
make clean
return $?
}
install() {
echo "Executing install command..."
make install
return $?
}
remove() {
echo "Executing remove command..."
make remove
#rm "$HOME/.local/share/eog/plugins/libsdprompt-viewer.so"
#rm "$HOME/.local/share/eog/plugins/sdprompt-viewer.plugin"
#rm "$GIO_SCHEMAS_DIR/org.gnome.eog.plugins.sdprompt-viewer.gschema.xml"
#glib-compile-schemas "$GIO_SCHEMAS_DIR"
return $?
}
release() {
echo "Executing release command..."
# get the latest Git tag, or use a default version if no tags exist
local latest_tag=$(git describe --tags --abbrev=0 HEAD || echo "0.1")
## meson build -Drelease_version=$latest_tag && ninja -C build
## set the RELEASE_VERSION environment variable to the latest tag
## export RELEASE_VERSION=$latest_tag
## meson build && ninja -C build
return 1
}
#================================== START ==================================#
# if no arguments are provided, show the help message
if [ $# -eq 0 ]; then
echo "$SCRIPT_HELP"
exit 0
fi
# change to the script directory
cd "$SCRIPT_DIR"
# execute the appropriate function based on the first argument
SCRIPT_STATUS=0
case "$1" in
build)
build
SCRIPT_STATUS=$?
;;
run)
run
SCRIPT_STATUS=$?
;;
clean)
clean
SCRIPT_STATUS=$?
;;
install)
install
SCRIPT_STATUS=$?
;;
remove)
remove
SCRIPT_STATUS=$?
;;
release)
release
SCRIPT_STATUS=$?
;;
*)
echo "Invalid command: $1"
echo "$SCRIPT_HELP"
exit 1
;;
esac
echo "Exiting..."
exit $SCRIPT_STATUS