Skip to content

Commit c1955fd

Browse files
committed
improve image conversion
1 parent 5d5a14a commit c1955fd

File tree

4 files changed

+128
-18
lines changed

4 files changed

+128
-18
lines changed

scripts.tar.xz

432 Bytes
Binary file not shown.

scripts/set-plymouth

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ MoePlymouthURL="https://github.com/mifjpn/Moebuntu-kawaiiUbuntu-ToysOriginal/raw
44
MoePlymouthFileName=`echo $MoePlymouthURL|awk -F"/" '{print $NF}'`
55
MoePlymouthDirName="mmspinner"
66
MoePlymouthBackGroundFile="/usr/share/plymouth/themes/mmspinner/background-tile.png"
7+
MoePlymouthBackGroungFileName=`echo $MoePlymouthBackGroundFile|awk -F"/" '{print $NF}'`
78
PlymothThemePath="/usr/share/plymouth/themes"
89
MoeAlternativesPath="/usr/share/plymouth/themes/mmspinner/mmspinner.plymouth"
910
DetaultAlternativesPath="/usr/share/plymouth/themes/bgrt/bgrt.plymouth"
@@ -67,6 +68,15 @@ if [ ! $? -eq 0 ]; then
6768
echo " already Installed"
6869
fi
6970

71+
# Install imagemagick-2212291856
72+
echo " Install imagemagick"
73+
dpkg -s imagemagick >/dev/null 2>&1
74+
if [ ! $? -eq 0 ]; then
75+
sudo apt install -y imagemagick
76+
else
77+
echo " Already Installed"
78+
fi
79+
7080
# Download Plymouth
7181
echo " download $MoePlymouthFileName "
7282
curl -L $MoePlymouthURL --output "$TempDir/$MoePlymouthFileName"
@@ -90,8 +100,9 @@ echo " exist Moe Plymouth: `ls -d "$PlymothThemePath/$MoePlymouthDirName"`"
90100
sudo update-alternatives --set default.plymouth "$MoeAlternativesPath" >/dev/null 2>/dev/null
91101

92102
# Change login screen
93-
echo " Set Moebuntu basic plymouse screen image (Y)"
94-
echo -n "Or Set Original(or Example) plymouth png-file(N)?:"
103+
echo " Set Moebuntu basic plymouth screen image (Y)"
104+
# fix word for update 2212291928
105+
echo -n "Or Set Original(or Example) plymouth screen image(N)?:"
95106
if askyn; then
96107
# Moebuntu basic Change screen then not copy
97108
# Remove tempdir
@@ -107,7 +118,7 @@ if askyn; then
107118
exit 0
108119
fi
109120
# Choose Change Screen
110-
read -p "Please drag-and-drop plymouth png-file or push to set return(Example):" FileDrop
121+
read -p "Please drag-and-drop plymouth (png etc.)image file or push only return to set Example image:" FileDrop
111122
if [ "$FileDrop" = "" ]; then
112123
# Null return
113124
# Set to default
@@ -152,8 +163,32 @@ if [ "$FileDrop" = "" ]; then
152163
echo ""  
153164
exit 0
154165
fi
155-
echo " set Plymouth tile picture to $PlymouthFile"
156-
sudo cp $PlymouthFile $MoePlymouthBackGroundFile
166+
# file conversion-2212291856
167+
FileName=`echo $PlymouthFile|awk -F"/" '{print $NF}'`
168+
FileExtension=`echo ${FileName##*.}`
169+
echo "FileExtension is $FileExtension"
170+
if [ $FileExtension = "png" ] || [ $FileExtension = "PNG" ]; then
171+
echo " set Plymouth tile picture to $PlymouthFile"
172+
sudo cp $PlymouthFile $MoePlymouthBackGroundFile
173+
echo ""
174+
else
175+
echo " Convert $PlymouthFile to $TempDir/$MoePlymouthBackGroungFileName"
176+
ReturnValue=`convert $PlymouthFile $TempDir/$MoePlymouthBackGroungFileName`
177+
if [ "$ReturnValue" != "" ]; then
178+
echo "Can't convert to PNG-image"
179+
echo "Can not change Plymouth picture"
180+
# remove temp-dir
181+
rm -rf $TempDir
182+
echo ""
183+
echo -n "Hit Any Key:"
184+
read -r -n 1 -s answer
185+
echo ""  
186+
exit 0
187+
fi
188+
sudo cp $TempDir/$MoePlymouthBackGroungFileName $MoePlymouthBackGroundFile
189+
echo "Done"
190+
echo ""
191+
fi
157192
fi
158193
# remove temp-dir
159194
rm -rf $TempDir

scripts/set-theme

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ if [ ! $? -eq 0 ]; then
6161
echo " Already Installed"
6262
fi
6363

64+
# Install imagemagick-2212291856
65+
echo " Install imagemagick"
66+
dpkg -s imagemagick >/dev/null 2>&1
67+
if [ ! $? -eq 0 ]; then
68+
sudo apt install -y imagemagick
69+
else
70+
echo " Already Installed"
71+
fi
72+
6473
# Download Theme
6574
echo " download $ThemeFileName"
6675
curl -L $ThemeUrl --output "$TempDir/$ThemeFileName"
@@ -102,9 +111,10 @@ if askyn; then
102111

103112
# login png-file
104113
echo "Set Moebuntu basic login picture(Y)"
105-
echo -n " Or Original(or Example) login png-picture(N)?:"
114+
# sentence modified at 2212291859
115+
echo -n " Or Original(or Example) login image(N)?:"
106116
if ! askyn; then
107-
read -p "Please drag-and-drop login png-file or push to set return(Example):" FileDrop
117+
read -p "Please drag-and-drop login png(or other)image-file or push to only return to set Example image:" FileDrop
108118
if [ "$FileDrop" = "" ]; then
109119
# set default login picture
110120
# download default login picture
@@ -144,9 +154,33 @@ if askyn; then
144154
echo ""  
145155
exit 0
146156
fi
147-
sudo cp $LoginFile /usr/share/themes/$ThemeDirName/gnome-shell/moebuntu_bg.png
148-
echo "Done"
149-
echo ""
157+
# file conversion-2212291856
158+
FileName=`echo $LoginFile|awk -F"/" '{print $NF}'`
159+
FileExtension=`echo ${FileName##*.}`
160+
echo "FileExtension is $FileExtension"
161+
if [ $FileExtension = "png" ] || [ $FileExtension = "PNG" ]; then
162+
sudo cp $LoginFile /usr/share/themes/$ThemeDirName/gnome-shell/moebuntu_bg.png
163+
echo "Done"
164+
echo ""
165+
else
166+
echo " Convert $LoginFile to $TempDir/moebuntu_bg.png"
167+
ReturnValue=`convert $LoginFile $TempDir/moebuntu_bg.png`
168+
# echo " ReturnValue is $ReturnValue"
169+
if [ "$ReturnValue" != "" ]; then
170+
echo "Can't convert to PNG-image"
171+
echo "Can not change login picture"
172+
# remove temp-dir
173+
rm -rf $TempDir
174+
echo ""
175+
echo -n "Hit Any Key:"
176+
read -r -n 1 -s answer
177+
echo ""  
178+
exit 0
179+
fi
180+
sudo cp $TempDir/moebuntu_bg.png /usr/share/themes/$ThemeDirName/gnome-shell/moebuntu_bg.png
181+
echo "Done"
182+
echo ""
183+
fi
150184
fi
151185
else
152186
echo "=set login to Moe-ized="

scripts/wallmanager

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ InstallCurl() {
2222
fi
2323
echo ""
2424
}
25+
26+
# Install imagemagick-2212291856
27+
InstallImagemagick() {
28+
echo " Install imagemagick"
29+
dpkg -s imagemagick >/dev/null 2>&1
30+
if [ ! $? -eq 0 ]; then
31+
sudo apt install -y imagemagick
32+
else
33+
echo " Already Installed"
34+
fi
35+
}
36+
2537
#Ask Yn
2638
askyn() {
2739
echo -n "(Y/N)? "
@@ -48,8 +60,9 @@ if [ "$1" = "install" ]; then
4860
# install
4961
echo "=Install Desktop Wallpaper="
5062
InstallCurl;
63+
InstallImagemagick;
5164
# Ask filename of wallpaper
52-
read -p "Please drag-and-drop wall jpg or png image file or push to set return(Example):" FileDrop
65+
read -p "Please drag-and-drop wall (png etc) image file or push only return to set example image:" FileDrop
5366
if [ "$FileDrop" = "" ]; then
5467
# set default login picture
5568
# download default login picture
@@ -107,15 +120,36 @@ if [ "$1" = "install" ]; then
107120
ConstMoeWallFileName=$ConstWallFileNamePng
108121
else
109122
echo "extention is not jpg or png."
110-
echo "please drag and drop jpg or png image file."
111-
echo "can not change desktop wallpaper"
112-
# remove temp-dir
123+
echo " convert to png file"
124+
# convert to png
125+
ConstMoeWallFileName=$ConstWallFileNamePng
126+
echo "FileExtension is $FileExtension"
127+
echo " Convert $WallFileFullPath to $TempDir/$ConstMoeWallFileName"
128+
ReturnValue=`convert $WallFileFullPath $TempDir/$ConstMoeWallFileName`
129+
if [ "$ReturnValue" != "" ]; then
130+
echo "Can't convert to PNG-image"
131+
echo "Can not change wallpaper picture"
132+
# remove temp-dir
133+
rm -rf $TempDir
134+
echo ""
135+
echo -n "Hit Any Key:"
136+
read -r -n 1 -s answer
137+
echo ""  
138+
exit 0
139+
fi
140+
sudo cp "$TempDir/$ConstMoeWallFileName" "$SYSWallDir/$ConstMoeWallFileName"
141+
echo "Done"
142+
echo " setting $TempDir/$ConstMoeWallFileName to $SYSWallDir/$ConstMoeWallFileName"
143+
gsettings set org.gnome.desktop.background picture-uri "file://$SYSWallDir/$ConstMoeWallFileName"
144+
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SYSWallDir/$ConstMoeWallFileName"
145+
echo "Done"
146+
echo " remove temp folder $TempDir"
113147
rm -rf $TempDir
114148
echo ""
115149
echo -n "Hit Any Key:"
116150
read -r -n 1 -s answer
117-
echo ""  
118-
exit 0
151+
echo ""
152+
exit 0
119153
fi
120154
echo " copy $WallFileFullPath to $SYSWallDir"
121155
sudo cp "$WallFileFullPath" "$SYSWallDir/$ConstMoeWallFileName"
@@ -124,14 +158,21 @@ if [ "$1" = "install" ]; then
124158
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SYSWallDir/$ConstMoeWallFileName"
125159
echo "Done"
126160
echo " remove temp folder $TempDir"
161+
# remove temp-dir
127162
rm -rf $TempDir
128163
echo ""
129164
echo -n "Hit Any Key:"
130165
read -r -n 1 -s answer
131-
echo ""
166+
echo ""  
132167
exit 0
133168
fi
134-
# remove
169+
rm -rf $TempDir
170+
echo ""
171+
echo -n "Hit Any Key:"
172+
read -r -n 1 -s answer
173+
echo ""
174+
exit 0
175+
# remove
135176
elif [ "$1" = "remove" ]; then
136177
echo "=Remove Moe desktop wallpaper ${MoeWallFileName%.*} and set detault="
137178
echo " seting to $DefaultWallFileName"

0 commit comments

Comments
 (0)