Skip to content

Commit

Permalink
feat: replace same name theme and not allow empty names
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysMb committed Oct 20, 2022
1 parent f66e8d0 commit 4822bb8
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions dtg.sh
Original file line number Diff line number Diff line change
@@ -11,8 +11,13 @@ darkImagePath=$(kdialog --getopenfilename $HOME 'image/*')
darkImageExtension=$(echo "${darkImagePath##*.}")

## Show input to user to write the theme name
themeName=$(kdialog --title "Dynamic Theme Generator - Theme name" --inputbox "What name would you like to
use?" "DynamicTheme")
while [ ! "$themeName" ]
do
themeName=$(kdialog --title "Dynamic Theme Generator - Theme name" --inputbox "What name would you like to use?" "DynamicTheme")
if [ ! "$themeName" ]; then
kdialog --error "Name should not be empty!"
fi
done

## Get screen resolution
screenResolution=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
@@ -21,21 +26,26 @@ screenResolution=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+
dbusRef=`kdialog --title "Dynamic Theme Generator - Generating Files" --progressbar "Generating the metadata file" 3`
qdbus-qt5 $dbusRef Set "" value 1

## Remove old wallpaper if wallpaper with same name exists
wallpaperPath="$HOME/.local/share/wallpapers/$themeName"
if [ -d "$wallpaperPath" ]; then
rm -r $wallpaperPath
fi

## Create Metadata file
wallpaperPath=$HOME/.local/share/wallpapers/$themeName
mkdir -p "$wallpaperPath"
touch $wallpaperPath/metadata.desktop
touch "$wallpaperPath/metadata.desktop"

## Write in Metadata file
echo "[Desktop Entry]" >> $wallpaperPath/metadata.desktop
echo "Name=$themeName" >> $wallpaperPath/metadata.desktop
echo "[Desktop Entry]" >> "$wallpaperPath/metadata.desktop"
echo "Name=$themeName" >> "$wallpaperPath/metadata.desktop"

## Show progressbar - Second step
qdbus-qt5 $dbusRef setLabelText "Creating folders and copying the LIGHT image"
qdbus-qt5 $dbusRef Set "" value 2

## Copy LIGHT image
lightImageFolder=$wallpaperPath/contents/images
lightImageFolder="$wallpaperPath/contents/images"
mkdir -p "$lightImageFolder"
cp "$lightImagePath" "$lightImageFolder/$screenResolution.$lightImageExtension"

@@ -44,7 +54,7 @@ qdbus-qt5 $dbusRef setLabelText "Creating folders and copying the DARK image"
qdbus-qt5 $dbusRef Set "" value 3

## Copy DARK image
darkImageFolder=$wallpaperPath/contents/images_dark
darkImageFolder="$wallpaperPath/contents/images_dark"
mkdir -p "$darkImageFolder"
cp "$darkImagePath" "$darkImageFolder/$screenResolution.$darkImageExtension"

0 comments on commit 4822bb8

Please sign in to comment.