X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=bin%2Fsetlogin;h=133a8d7eeecdf47d818cc64a866b4d1c2d6055b7;hb=240ca5b4d23823ef2ac8b65c34cb7bc39a81bd5c;hp=ee71ada7a01ce0208d39b525bc3d3d06d997c2bd;hpb=59e4b094ca914ea2ff06f07da91a6c201cc7e466;p=clearscm.git diff --git a/bin/setlogin b/bin/setlogin index ee71ada..133a8d7 100755 --- a/bin/setlogin +++ b/bin/setlogin @@ -1,37 +1,140 @@ #!/bin/bash -# Simple script to set the login background -if [ "$UID" != 0 ]; then - echo "Must be run as root" - exit 1 +codename=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) + +if [ "$codename" == "impish" ] +then +source="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource" +else +echo " +---------------------------------------- +Sorry, Script is only for Ubuntu 21.10 +Exiting... +----------------------------------------" +exit 1 fi -if [ $# != 1 ]; then - echo "Usage: $0 " - exit 1 +pkg=$(dpkg -l | grep libglib2.0-dev >/dev/null && echo "yes" || echo "no") +if [ "$pkg" == "no" ] +then +echo " +----------------------------------------------------------------------------------------------------- +Sorry, the package 'libglib2.0-dev' is not installed. Install the package and then run this Script. +For now, Exiting... +-----------------------------------------------------------------------------------------------------" +exit 1 fi -# Not sure why Yaru was picked as the source... -source="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource" -color="#000000" +############################################################################################ +case "$1" in ############################################################################### +############################################################################################ +--set) +############################################################################################ + +if [ "$UID" != "0" ] +then +echo "This Script must be run with sudo" +exit 1 +fi + +echo " +------------------------------------------------------------------------------------------------------- +Please note that after setting login screen background, +>>>>>>>>> Reboot is highly recomonded to see the changes <<<<<<<<<<<< -imagefile=$1 +Do you want to proceed now? [Yes/no] Type n to exit, or press enter to proceed. +-------------------------------------------------------------------------------------------------------" +read answer -if [ ! -e "$imagefile" ]; then - echo "$imagefile not found" - exit 1 +if [ "$answer" == "n" ] || [ "$answer" == "N" ] +then +echo "Exiting..." +exit 1 fi -imagefile=$(echo $imagefile | sed 's/ /%20/g') +echo " +Please Choose any one number from below. +------------- +1. for Image +2. for Color +-------------" +read a + +if [ -z $a ] +then +echo "Option is not selected. +Exiting..." +exit 1 +fi + +if [ "$a" == "1" ] +then +echo "Enter Image Path for Login Screen +---------------------------------------------------- +Example1: /usr/share/backgrounds/2.jpg +Example2: /usr/local/share/backgrounds/spaceship.png +Example3: /home/impish/Downloads/myBG.jpeg +----------------------------------------------------" +read b + +elif [ "$a" == "2" ] +then +echo " +Enter Hex Color Code for Login Screen (you may note down colors of your choice from this link https://www.color-hex.com/) +------------------------------------------------------------------------------------------------------------------------- +Example1: #00ff00 +Example2: #fca +Example3: #456789 +Example4: #123 +Example5: #FF00FF +-------------------------------------------------------------------------------------------------------------------------" +read c +fi + +if [ -z $b ] && [ -z $c ] +then +echo "Input is not Provided. +Exiting..." +exit 1 +fi + +if [ -z $c ] +then +color="#042320" +else +color="$c" +fi + +if ! [ -z $c ] +then + if ! [[ $c =~ ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ ]]; then + echo " +------------------------------------------------------------------------------------------------------------ + Sorry it is not a valid Hex color, Please choose the valid HEX color first and then run this script. +------------------------------------------------------------------------------------------------------------" + exit 1 + fi +fi + +if ! [ -z $b ] +then + if ! [ -e $b ]; then + echo " +--------------------------------------------------------------------------------------------------- +Image path you entered does not exist, script defined background color is going to be used for now. +Please notedown the correct file path of the Image and then run this script. +---------------------------------------------------------------------------------------------------" + fi +fi prefix="/org/gnome/shell/theme" -dest="/usr/local/share/gnome-shell/theme/focalgdm3" +dest="/usr/local/share/gnome-shell/theme/impishgdm" -install -D /dev/null $dest/gdm3.css -install -D /dev/null $dest/focalgdm3.gresource.xml +install -D /dev/null $dest/gdm.css +install -D /dev/null $dest/impishgdm.gresource.xml install -d $dest/icons/scalable/actions -gresource extract $source $prefix/gdm3.css > $dest/original.css +gresource extract $source $prefix/gdm.css > $dest/original.css gresource extract $source $prefix/checkbox.svg > $dest/checkbox.svg gresource extract $source $prefix/checkbox-off.svg > $dest/checkbox-off.svg gresource extract $source $prefix/checkbox-focused.svg > $dest/checkbox-focused.svg @@ -52,16 +155,16 @@ gresource extract $source $prefix/icons/scalable/actions/eye-open-negative-fille echo '@import url("resource:///org/gnome/shell/theme/original.css"); #lockDialogGroup { - background: '$color' url(file://'$imagefile'); + background: '$color' url(file://'$b'); background-repeat: no-repeat; background-size: cover; - background-position: center; }' > $dest/gdm3.css + background-position: center; }' > $dest/gdm.css echo ' original.css - gdm3.css + gdm.css toggle-off.svg checkbox-off.svg toggle-on.svg @@ -80,25 +183,52 @@ echo ' icons/scalable/actions/pointer-double-click-symbolic.svg icons/scalable/actions/eye-open-negative-filled-symbolic.svg -' > $dest/focalgdm3.gresource.xml +' > $dest/impishgdm.gresource.xml cd $dest - -glib-compile-resources focalgdm3.gresource.xml - -mv focalgdm3.gresource .. - +glib-compile-resources impishgdm.gresource.xml +mv impishgdm.gresource .. rm -r $dest - -update-alternatives --quiet --install /usr/share/gnome-shell/gdm3-theme.gresource gdm3-theme.gresource /usr/local/share/gnome-shell/theme/focalgdm3.gresource 0 -update-alternatives --quiet --set gdm3-theme.gresource /usr/local/share/gnome-shell/theme/focalgdm3.gresource - -check=$(update-alternatives --query gdm3-theme.gresource | grep Value | grep /usr/local/share/gnome-shell/theme/focalgdm3.gresource >/dev/null && echo "pass" || echo "fail") - -if [ "$check" == "pass" ]; then - echo "Success" - exit 0 +update-alternatives --quiet --install /usr/share/gnome-shell/gdm-theme.gresource gdm-theme.gresource /usr/local/share/gnome-shell/theme/impishgdm.gresource 0 +update-alternatives --quiet --set gdm-theme.gresource /usr/local/share/gnome-shell/theme/impishgdm.gresource + +check=$(update-alternatives --query gdm-theme.gresource | grep Value | grep /usr/local/share/gnome-shell/theme/impishgdm.gresource >/dev/null && echo "pass" || echo "fail") +if [ "$check" == "pass" ] +then +echo " + --------- + |Success| + ---------" +else +echo Failure +exit 1 +fi +;; +############################################################################################ +--reset) ################################################################################### +############################################################################################ + +if [ -e /usr/local/share/gnome-shell/theme/impishgdm.gresource ] +then +rm /usr/local/share/gnome-shell/theme/impishgdm.gresource +update-alternatives --quiet --set gdm-theme.gresource "$source" +cd /usr/local/share +rmdir --ignore-fail-on-non-empty -p gnome-shell/theme +echo " + --------------- + |Reset Success| + ---------------" else - echo "Failure" - exit 1 +echo " +----------------------------------------------------------------------------- +No need, Already Reset. (or unlikely background is not set using this Script.) +-----------------------------------------------------------------------------" +exit 1 fi +;; +############################################################################################ +*) ######################################################################################### +############################################################################################ +echo "Use the parameter '--set' or '--reset'; example: './impishgdm --set' or './impishgdm --reset'" +exit 1 +esac