Compare commits

...

125 commits
v0.2.2 ... main

Author SHA1 Message Date
4912cfa2c8 Added preliminary work on a cleanup script to move files around 2023-08-21 00:41:30 -05:00
9cee7f2904 Cleaned up more, removed analytics 2023-08-20 18:22:29 -05:00
b958afb09b Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2023-08-20 18:19:51 -05:00
965477d62b Updated installer script, made a bit more streamlined and fixed errors 2023-08-20 18:19:02 -05:00
e82a0cf000 Added support for OpenSUSE update checks with Zypper 2023-05-07 17:44:44 -05:00
G2
f78aed8316
Update README.md 2023-03-08 19:35:49 -06:00
G2
979978a7f8 Added update tracking to installer 2023-03-07 14:00:44 -06:00
G2
54f3619274 Bumped version, v1.1.2 2023-03-07 10:32:06 -06:00
G2
bd27870290 Fixed #6, used proper array indexing technique 2023-03-07 10:29:30 -06:00
G2
741fe542f1 Bumped version, v1.1.1 2023-03-07 09:53:34 -06:00
G2
b905684b63 Fixed issues with strict mode by removing it for now. Fixes #5 2023-03-07 09:41:36 -06:00
G2
68ab6a6310 Updated installer to download itself properly 2023-03-07 09:41:11 -06:00
4e5b2a848e Bumped version, 1.1.0 2023-03-07 00:20:30 -06:00
61ddc11af7 Fixed automatic update check in both welcome.sh and installer 2023-03-06 23:52:55 -06:00
44c14ad494 Cleaned up install.sh even more, conformed to all shellcheck rules 2023-03-06 23:49:23 -06:00
a863f8ddc6 Significantly cleaned up install script, dropped support for wget 2023-03-06 19:00:50 -06:00
49563932e0 Removed wget support, too hard to maintain 2023-03-06 18:32:01 -06:00
e072e7c7fc Fixed a bunch of small possible issues with the script 2023-03-06 18:06:57 -06:00
b7608a59d0 Fixed major issue with apt update checking on debian systems 2023-03-06 16:58:39 -06:00
bd0f3f2cc0 Added automatic update checking functionality 2022-11-29 22:45:46 -06:00
c58f9f5224 Added more comments, changed to strict mode (might cause issues) 2022-11-26 14:42:16 -06:00
84874298c4 Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-11-26 14:40:50 -06:00
56883965c5 Streamlined install script, added support for checking latest release automatically 2022-11-26 14:40:23 -06:00
G2
24a1dd5319
Update README.md 2022-11-25 04:11:39 -06:00
cc7ec85760 Added a possibly better way to check for updates on Arch 2022-11-25 01:59:07 -06:00
74a570a107 Used bash strict mode to clean up the code a bit, couldn't get everything 2022-11-25 01:37:56 -06:00
decec76c61 Version bump, v1.0.5 2022-11-25 00:52:05 -06:00
bdcb586589 Supressed random error, cleaned up update code 2022-11-25 00:48:22 -06:00
5dcf4a77f8 Fixed update not getting checked... again 2022-11-25 00:45:14 -06:00
G2
df8decfd6e
Version bump 2022-11-25 00:37:11 -06:00
c6c9254a9d Fixed ZSH issues, added strict mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/) 2022-11-25 00:35:59 -06:00
g2
4226a00c31 Fixed another error 2022-09-30 10:13:38 -05:00
g2
5acea7fd34 Fixed file paths 2022-09-30 10:10:06 -05:00
g2
aee6ee9e67 version bump, 1.0.4 2022-09-30 09:11:34 -05:00
g2
2b801c0a57 version bump 1.0.4 2022-09-30 09:06:30 -05:00
g2
1760701f89 Reverted changes 2022-09-30 08:58:07 -05:00
g2
5335b5a6bb Fixed async update check, added more streamlined system 2022-09-30 08:57:19 -05:00
g2
ccfb158843 Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-09-30 08:31:04 -05:00
g2
df5d43dea3 Add timeout for update check, 5 seconds 2022-09-30 08:30:45 -05:00
g2
05f0fd6ec8 Fixed formatting 2022-09-30 08:30:27 -05:00
G2
5052c35831
Merge pull request #4 from ClonkDroid/main
Fix LC_LOCALE, fixes issue #3
2022-09-30 08:26:28 -05:00
ClonkDroid
affac2e291
Fix LC_LOCALE 2022-09-30 11:33:56 +02:00
g2
a44b54186b Version bump, 1.0.3 2022-09-28 14:40:45 -05:00
g2
ab6a2daf8d Version bump, 1.0.3 2022-09-28 14:37:35 -05:00
g2
69330845b7 Fixed wording in comment 2022-09-28 14:35:29 -05:00
G2
6265b2f27c
Close #3, printf error on non "en_US.UTF-8" 2022-09-28 14:30:41 -05:00
G2-Games
eb10f90ce1 Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-09-21 14:39:28 -05:00
G2-Games
f82d1c4098 Fixed spot where cURL was the only option, added Wget 2022-09-21 14:38:53 -05:00
G2
ac77fa236f
Update README.md 2022-09-21 13:54:06 -05:00
G2-Games
544ed01199 Improved updater and uninstaller, should have complete compatibility with MacOS 2022-09-21 12:56:44 -05:00
G2
d576cf98fb
Update README.md 2022-09-21 09:22:18 -05:00
1b8ffa05a9 Made installer prettier 2022-09-21 02:26:11 -05:00
3da39bfefb Update README 2022-09-20 17:34:48 -05:00
3ce09125dc Improved config updating system 2022-09-20 15:34:36 -05:00
5d1920dfb2 Patch, fixed ZSH line removal 2022-09-20 15:26:58 -05:00
G2-Games
caa1e26c0f More fixes 2022-09-20 13:27:33 -05:00
G2-Games
ee34c250dd Finalized config version checker 2022-09-20 13:15:13 -05:00
G2-Games
a827741e69 Cfg version bump 2022-09-20 13:06:04 -05:00
G2-Games
a0b7d43b4f Fix version checking, revert changes 2022-09-20 13:03:48 -05:00
G2-Games
355ba1aa86 Version bump, 1.0.2 2022-09-20 12:39:21 -05:00
G2-Games
6340d87388 Added checks for config version to updater 2022-09-20 12:34:10 -05:00
G2-Games
d28195b401 Fixed overwriting config.cfg 2022-09-20 12:23:18 -05:00
G2-Games
1bdf2a6ff6 Updated config options, version bump 2022-09-20 12:22:58 -05:00
36870bc04e Added toggle for update checker 2022-09-20 12:09:39 -05:00
316cc6fda8 Fixed issue with failsafe 2022-09-20 03:02:24 -05:00
G2
b3ab8b3b04
Update install.sh 2022-09-20 03:00:47 -05:00
51159c3b39 Fixed install for Zsh 2022-09-20 02:52:58 -05:00
f6aface51a Much improved many parts of the install file, should be much more reliable 2022-09-20 02:31:31 -05:00
666601105a Small change 2022-09-20 01:23:33 -05:00
bd06940b6a Streamlined version tag use 2022-09-20 01:20:36 -05:00
f26c99f2a5 Version flag addition 2022-09-20 01:16:55 -05:00
c01e097140 Fixed version number 2022-09-20 00:03:47 -05:00
f8d862d353 Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-09-19 23:58:45 -05:00
63423aa0e0 Fixed download path 2022-09-19 23:58:15 -05:00
G2
6286a69dcd
Update README.md 2022-09-19 21:08:46 -05:00
beb2e27859 Version bump, 1.0.1 2022-09-19 20:26:25 -05:00
e2d183adaa Version bump, 1.0.1 2022-09-19 20:22:21 -05:00
512541775d Made update dialogs more descriptive 2022-09-19 19:35:30 -05:00
942e29f0eb Added version info to installer, and to upgradey 2022-09-19 19:19:26 -05:00
e1956f0df1 Added support for battery level on Mac 2022-09-19 19:17:10 -05:00
765a471085 Fixed "egrep" error in zsh 2022-09-19 19:01:24 -05:00
5f4008459c Fixed installer for older versions 2022-09-19 17:04:28 -05:00
G2
b2da704a09
Update README.md 2022-09-19 16:47:11 -05:00
G2
857d4d9d4e
Update README.md 2022-09-19 16:45:05 -05:00
G2-Games
5c75716b5d Fixed path again 2022-09-19 16:36:00 -05:00
G2-Games
7e588531de Fixed config path 2022-09-19 16:33:59 -05:00
G2-Games
031b03d197 Fixed install when older version than 1.0 specified 2022-09-19 16:32:12 -05:00
G2-Games
7ae07f7650 Updated config settings, version bump 2022-09-19 16:28:02 -05:00
G2-Games
aeeac56c1f Updated and streamlined script, added updater to install script 2022-09-19 16:21:08 -05:00
c4a0aa8899 Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-09-18 21:56:43 -05:00
f7f3af3828 Update config 2022-09-18 21:56:35 -05:00
G2
79255119bf
Update config 2022-09-18 21:53:36 -05:00
804aa8701f Made uninstallation work on MacOS 2022-09-18 20:05:28 -05:00
f2f8d567db Version bump, 0.3.0 2022-09-18 19:43:34 -05:00
f4477e87e1 Added new check for apt instead of apt-get 2022-09-18 19:40:42 -05:00
b5060b4658 Made install use proper home directory 2022-09-18 19:25:24 -05:00
a6b5f4ded8 Fixed shell detection, made it more reliable (hopefully) 2022-09-18 18:15:43 -05:00
4c9d4bccc4 Reverted detection change 2022-09-18 17:57:19 -05:00
8f7fc68ea1 Updated shell detection for installer, should work on Macs now 2022-09-18 17:53:38 -05:00
87e4668f99 Added version tag 2022-09-18 14:34:36 -05:00
935bc210f9 Changed variable name to be more descriptive 2022-09-18 13:02:58 -05:00
87a509c991 Added toggle for "good" instead of "It's" for greetings 2022-09-18 13:01:53 -05:00
G2
45e00f997d
Update README.md 2022-09-18 12:02:23 -05:00
5215f964ae Polished Homebrew support 2022-09-18 11:53:01 -05:00
9fbcf0fb6d Added Homebrew support 2022-09-18 03:34:08 -05:00
457788b3fe Merge branch 'main' of https://github.com/G2-Games/welcome.sh 2022-09-18 02:43:43 -05:00
ca1a6c91ad Update Configs section 2022-09-18 02:43:05 -05:00
G2
4e2e76251c
Create README.md 2022-09-18 02:42:28 -05:00
G2
9703a47fe2
Updated settings 2022-09-18 02:41:55 -05:00
378ecc31d2 Fixed issue where APT errors could cause undesirable output 2022-09-18 02:34:54 -05:00
G2
b1802eb490
Update README.md 2022-09-18 00:35:32 -05:00
2370c92cb0 Version bump, 0.2.5 2022-09-18 00:13:21 -05:00
1e0e9e37d4 Added catch for battery level for devices without a battery 2022-09-18 00:08:59 -05:00
G2-Games
87fea9d2f0 Made change simpler 2022-09-17 23:58:03 -05:00
G2-Games
13a72920d5 Fixed battery level showing more than 100% 2022-09-17 23:57:13 -05:00
9575f5e9e1 Installer niceities update 2022-09-06 08:50:21 -05:00
G2
081e621b7c
Update README.md 2022-09-06 00:30:12 -05:00
3d293d9b08 bugfixes 2022-09-06 00:29:17 -05:00
b45861ecdb Version bump, 0.2.4 2022-09-06 00:02:28 -05:00
200f085aa6 Fixes 2022-09-06 00:01:13 -05:00
a165ed66b0 Fixed time display when under 10:00, fixed random color luma values 2022-09-05 23:27:33 -05:00
G2
9e8367b4d0
Update README.md 2022-09-05 23:24:11 -05:00
8b577eb9e1 Version bump, 0.2.3 2022-09-05 03:26:03 -05:00
bb426a101c Added random greetings and 12/24 hour clock toggle 2022-09-04 20:52:00 -05:00
a8f761e309 Version bump, 0.2.2 2022-09-04 19:57:59 -05:00
5 changed files with 519 additions and 204 deletions

View file

@ -1,5 +1,6 @@
# welcome.sh # welcome.sh
![image](https://user-images.githubusercontent.com/72430668/188241809-fd94292e-23a4-4bba-bb76-82b863bbdddb.png) ![image](https://user-images.githubusercontent.com/72430668/190891298-c08c8ad8-9270-4549-b3ae-85e48ae2748b.png)
### A nice welcome script for Bash and Zsh ### A nice welcome script for Bash and Zsh
This is a nice little script for your `.bashrc` or `.zshrc` that greets you on every launch, with some helpful (and customizable!) information. This is a nice little script for your `.bashrc` or `.zshrc` that greets you on every launch, with some helpful (and customizable!) information.
@ -9,10 +10,19 @@ My goal with this script is to keep it simple, just a single line that gives use
- Relatively fast - Relatively fast
- <span title="Please let me know of other things to support!">Works across many distros (update checking support)</span> - <span title="Please let me know of other things to support!">Works across many distros (update checking support)</span>
- Clean and simple - Clean and simple
- Customizable
- Easy to install and update
#### Requirements:
- Terminal with 24-bit true color support
- Can check with `printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"`, will return `TRUECOLOR` in Brown if supported<br>
<sup>Source: [https://github.com/termstandard/colors](https://github.com/termstandard/colors)</sup>
- [List of supported terminal emulators](https://github.com/termstandard/colors#truecolor-support-in-output-devices)
- A modern version of Bash or Zsh (eg. the `/bin/sh` shell in Ubuntu does **not** work)
<hr> <hr>
### Installing: ### Installing:
#### Via Curl #### Automatic Installation via Curl
<sub>Bash:</sub> <sub>Bash:</sub>
``` ```
bash -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)" bash -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)"
@ -21,56 +31,66 @@ bash -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/in
``` ```
zsh -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)" zsh -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)"
``` ```
#### Or wget
<sub>Bash:</sub>
```
bash -c "$(wget -q https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh -O -)"
```
<sub>Zsh:</sub>
```
zsh -c "$(wget -q https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh -O -)"
```
It installs to `~/.welcome/welcome.sh`, and adds a line to the bottom of `~/.bashrc` or `~/.zshrc` It installs to `~/.welcome/welcome.sh`, and adds a line to the bottom of `~/.bashrc` or `~/.zshrc`
Run again to uninstall. Uninstalling will remove it from both Bash and Zsh.
#### Manual Installation #### Manual Installation
To use it, download `welcome.sh` and place it in your home directory. Then add `/home/$USER/welcome.sh` to your `.bashrc`. To install it manually, download the latest `welcome.sh` from <a href="https://github.com/G2-Games/welcome.sh/releases/latest">releases</a> and place it in your home directory. Then add `bash ~/welcome.sh` to your `.bashrc`. It works without the config file, but you can also add that to your home directory for easier manual updates.
### Updating: ### Updating:
WIP Run the script again to check for an update. If you have an older version it will prompt you. You can update **from** any version **to** any newer version. The proper files will be downloaded as necessary.
Currently you can update by uninstalling and reinstalling, but this wipes all settings. I am working on making a better way to do this.
<hr> <hr>
### Configs: ### Configs:
To configure settings, open `welcome.sh` in your text editor of choice and go to the bottom. There, you'll find a few settings: To configure settings, open `~/.welcome/config.cfg` in your text editor of choice. There, you'll find a few settings:
```bash ```bash
#=========SETUP========# #==================SETUP=================#
# Select which parts you want active by commenting them out # # Select which parts you want active by #
# For example, on a desktop, disabling the battery message # # commenting them out. For example, on a #
# is a good idea. You can also re order them to change how # # desktop, disabling the battery message #
# they display! # # is a good idea. You can also re-order #
# them to change how they display! #
#========================================#
flatpakupd="off" # Check for flatpak updates, this slows startup down A LOT greetings=("Welcome" "Greetings" "Hello" "Hi") # Add your own greetings!
rechargenotif="off" # Notify that you should recharge if below 15% randgreeting="off" #< Turn the random greetings on (eg. "Hello <user>, Hi <user>")
twelvehour="on" #< Switch between 12 and 24 hour time (eg. 8:00 PM vs 20:00)
rechargenotif="off" #< Notify that you should recharge if below 15%
updatecheck="on" #< Check for all updates, slows startup a bit
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
displaydate="off" #< Unused so far
welcome #=========COLORS=======#
greeting NCOL='\e[0m'
clock BOLD='\e[1m'
#battery ITAL='\e[3m'
updates #< This makes startup slower UNDR='\e[4m'
echo # Properly line break at the end BLNK='\e[5m'
# Battery level colors
CRIT='\e[31m'
LOW='\e[33m'
NORM='\e[32m'
FULL='\e[3;4;92m'
TIME='\e[38;2;224;146;252;1m' # Clock color
DATE='\e[38;2;50;168;82;1m' # Future "Date" item color
USRC=$(randcolor) # Username color
# Greeting colors
NIGH='\e[38;2;200;107;209m'
MORN='\e[38;2;255;164;74m'
AFTN='\e[38;2;250;245;110m'
EVEN='\e[38;2;171;54;3m'
cfgversion=2
``` ```
Here, you can re-arrange the modules, and turn off and on flatpak and recharge notifications. I recommend leaving flatpak off as it makes startup incredibly slow.
I'm planning on making this config section a separate file later to make changing settings easier and updating easier.
<hr> <hr>
### TODO: ### TODO:
- [x] Add easier way to install and update
- [ ] Fix issues across other distros - [ ] Fix issues across other distros
- [ ] Add new features? - [ ] Add new features? (Please suggest!)
- [ ] Improve MacOS functionality

25
cleanup.sh Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
version=1
echo "Ensuring welcome.sh is installed in the new location..."
# Check if welcome.sh is installed in the old location
if [[ -f ~/.welcome ]]\
|| [[ -f ~/.welcome/welcome.sh ]]\
|| [[ -f ~/.welcome/config.cfg ]];
then
# Modify the files with proper paths
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
# Create the directories in the proper spots
mkdir -p ~/.config/welcome.sh/
mkdir -p ~/.local/bin/
# Move the welcome files to the proper folders
mv ~/.welcome/config.cfg ~/.config/welcome.sh/config.cfg
mv ~/.welcome/welcome.sh ~/.local/bin/welcome.sh
echo "welcome.sh is now installed in the new location!"
else
echo "welcome.sh is already installed properly!"
fi

41
config.cfg Normal file
View file

@ -0,0 +1,41 @@
#==================SETUP=================#
# Select which parts you want active by #
# commenting them out. For example, on a #
# desktop, disabling the battery message #
# is a good idea. You can also re-order #
# them to change how they display! #
#========================================#
greetings=("Welcome" "Greetings" "Hello" "Hi") # Add your own greetings!
randgreeting="off" #< Turn the random greetings on (eg. "Hello <user>, Hi <user>")
twelvehour="on" #< Switch between 12 and 24 hour time (eg. 8:00 PM vs 20:00)
rechargenotif="off" #< Notify that you should recharge if below 15%
updatecheck="on" #< Check for all updates, slows startup a bit
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
displaydate="off" #< Unused so far
#=========COLORS=======#
NCOL='\e[0m'
BOLD='\e[1m'
ITAL='\e[3m'
UNDR='\e[4m'
BLNK='\e[5m'
# Battery level colors
CRIT='\e[31m'
LOW='\e[33m'
NORM='\e[32m'
FULL='\e[3;4;92m'
TIME='\e[38;2;224;146;252;1m' # Clock color
DATE='\e[38;2;50;168;82;1m' # Future "Date" item color
USRC=$(randcolor) # Username color
# Greeting colors
NIGH='\e[38;2;200;107;209m'
MORN='\e[38;2;255;164;74m'
AFTN='\e[38;2;250;245;110m'
EVEN='\e[38;2;171;54;3m'
cfgversion=2

View file

@ -1,74 +1,207 @@
version=0.2.1 getVersion () {
bashrc="/home/$USER/.bashrc" local ver
zshrc="/home/$USER/.zshrc" ver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//')
originaldir=$PWD
environment=$(readlink /proc/$$/exe) if [ -z "$ver" ]; then
if [[ "$environment" = "/usr/bin/bash" ]] || [[ "$environment" = "/usr/bin/zsh" ]]; echo -e "\bUnknown"
then return
if ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
then
tput sc
echo "Welcome! Installing..."
cd /home/$USER
mkdir -p /home/$USER/.welcome
if which curl >/dev/null ;
then
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output /home/$USER/.welcome/welcome.sh
elif which wget >/dev/null ;
then
wget https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --P /home/$USER/.welcome/
else
echo "Cannot download, neither wget nor curl is available."
exit 1
fi fi
chmod +x /home/$USER/.welcome/welcome.sh
if [[ "$environment" = "/usr/bin/bash" ]]; echo "$ver"
then }
echo 'bash /home/$USER/.welcome/welcome.sh' >> $bashrc
echo "Installing to bashrc" # Universal read command for bash and zsh
elif [[ "$environment" = "/usr/bin/zsh" ]]; univRead () {
then echo -en "$1"
echo 'zsh /home/$USER/.welcome/welcome.sh' >> $zshrc echo -en "\n[\e[36mY/n\e[0m]"
echo "Installing to zshrc" if [[ "$environment" = "bash" ]]; then
fi read -p " " -r
cd "$originaldir" elif [[ "$environment" = "zsh" ]]; then
tput rc el ed read -q "REPLY? " -r
echo -e "\e[36mInstalled! \e[0m"
else
tput sc
echo -e "\e[35mwelcome.sh\e[0m already installed!"
echo -en "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?\n\e[36mY/n\e[0m"
if [[ "$environment" = "/usr/bin/bash" ]]
then
read -p " " -n 1 -r
elif [[ "$environment" = "/usr/bin/zsh" ]]
then
read -q "REPLY? " -n 1 -r
fi fi
echo echo
if [[ $REPLY =~ ^[Yy]$ ]] }
then
rm /home/$USER/.welcome/welcome.sh uninstall () {
rmdir /home/$USER/.welcome # Check if the user actually wishes to uninstall the script
if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ; univRead "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?"
then if ! [[ $REPLY =~ ^[Yy]$ ]]; then
line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
line=${line%:*}
sed -i "${line}d" $bashrc
fi
if grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ;
then
line=$(grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc)
line=${line%:*}
sed -i "${line}d" $zshrc
fi
tput rc el ed tput rc el ed
echo -e "\e[31mUninstall cancelled.\e[0m"
exit 0
fi
tput rc el ed
echo "Goodbye. Uninstalling..."
tput sc
rm ~/.welcome/welcome.sh 2> /dev/null
rm ~/.welcome/install.sh 2> /dev/null
rm ~/.welcome/config.cfg 2> /dev/null
rm ~/.welcome/config_old.cfg 2> /dev/null
rm -r ~/.welcome
#remove all lines that match the string
lines=$(grep -sn 'bash ~/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
for i in $lines; do
sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
done
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
for i in $lines; do
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
done
tput rc && tput el && tput ed
echo -e "\e[36mUninstalled! \e[0m" echo -e "\e[36mUninstalled! \e[0m"
else }
update () {
tput rc el ed tput rc el ed
echo -e "\e[32mCancelled. \e[0m" echo "Updating..."
tput sc
mkdir -p ~/.welcome
rm ~/.welcome/welcome.sh 2> /dev/null
rm ~/.welcome/install.sh 2> /dev/null
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh
curl -SL https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh --output ~/.welcome/install.sh
if [[ $vernum -ge 100 ]] && [[ $overcfg -gt 0 ]]; then
echo "Backing up: config.cfg >> config_old.cfg"
mv ~/.welcome/config.cfg ~/.welcome/config_old.cfg
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg --output ~/.welcome/config.cfg
fi
# Check for older versions and replace bashrc lines
lines=$(grep -sn 'bash ~/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g') # Find target line number
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g') # Format the line number properly (macos doesn't have Cut)
for i in $lines; do
sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
done
echo 'bash ~/.welcome/welcome.sh' >> "$bashrc"
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
for i in $lines; do
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
done
echo 'zsh ~/.welcome/welcome.sh' >> "$zshrc"
tput rc el ed
echo -e "\e[32mUpdated to v$version! \e[0m"
}
tput sc
if [[ -z "$1" ]] && [[ $1 != "auto" ]]; then
echo "Checking for latest release..."
fi
if ! [[ $(command -v curl) ]]; then
exit 1
fi
latestver=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/latest/download/welcome.sh | grep version | cut -d= -f2)
oldver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | cut -d= -f2 | sed 's/[.][.]*//g') && if [[ -z "$oldver" ]]; then oldver=0; fi
version="${1:-$latestver}"
if [[ $1 == "auto" ]] && [[ ${latestver//./} -le $oldver ]]; then
exit 0
elif [[ $1 == "auto" ]]; then
version=$latestver
fi
vernum=${version//./}
bashrc=~/.bashrc
zshrc=~/.zshrc
originaldir=$PWD
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
# Check if the environment is bash or zsh
if [[ "$environment" != "bash" ]] && [[ "$environment" != "zsh" ]]; then
tput rc
printf "\e[31;5mERROR:\e[0m \e[31;3mThis script can only be installed in Bash or Zsh.\e[0m\n"
printf "\e[32mYou appear to be using %s, which is not a valid shell for\n\
this script!\e[0m Please use \e[3mBash \e[0mor \e[3mZsh.\e[0m\n" "${environment}"
exit 1
fi
# Check if already installed
if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc &&
! grep -qs 'zsh ~/.welcome/welcome.sh' $zshrc &&
! grep -qs 'bash /home/$USER/.welcome/welcome.sh' $bashrc &&
! grep -qs 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
then
#==== Execute if first time installing...====#
tput rc
echo "Welcome! Installing v$version in $environment..."
tput sc
cd ~/ || exit 1
mkdir -p ~/.welcome
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh
curl -SL https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh --output ~/.welcome/install.sh
if [[ $vernum -ge 100 ]]; then
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg --output ~/.welcome/config.cfg
fi
chmod +x ~/.welcome/welcome.sh
if [[ "$environment" = "bash" ]]; then
echo "Installing to bashrc"
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
elif [[ "$environment" = "zsh" ]]; then
echo "Installing to zshrc"
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
fi
cd "$originaldir" || exit 1
tput rc el ed
echo -e "\e[36mInstalled! \e[0m"
else
#==== Execute if already installed...====#
tput rc sc el ed
mkdir -p ~/.welcome
if ! [[ $1 == "auto" ]]; then
echo -e "\e[35mwelcome.sh\e[0m already installed!"
else
echo -e "\e[32mUpdate available for \e[35mwelcome.sh!\e[0m"
fi
if [[ $vernum -gt $oldver ]]; then
# Pull the new configuration version from github
newCfgVer=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg | grep version | cut -d= -f2)
univRead "Do you want to \e[36mupdate \e[35mwelcome.sh\e[0m? (\e[36mv$(getVersion)\e[0m => \e[32mv$version\e[0m)"
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
tput rc sc el ed
echo -e "\e[31mUpdate cancelled.\e[0m"
update=0
else
update=1
fi
if [[ $newCfgVer -gt $(grep version ~/.welcome/config.cfg 2> /dev/null | cut -d= -f2) ]]; then
univRead "Newer \e[36mconfig\e[0m version available. Do you want to \e[31moverwrite\e[0m your \e[36mconfig\e[0m? \nA backup will be created in the \e[36m.welcome\e[0m folder."
if [[ $REPLY =~ ^[Yy]$ ]]; then
overcfg=1
fi
elif [[ $oldver -lt 100 ]]; then
overcfg=1
else
overcfg=0
fi
fi
if [[ update -gt 0 ]]; then
update
exit 0
fi
if ! [[ $1 == "auto" ]]; then
uninstall
exit 0
fi fi
fi
else
printf "\e[31;5mERROR:\e[0m \e[31;3mThis script can only be installed in bash or zsh.\e[0m\n"
fi fi

View file

@ -1,53 +1,71 @@
# For random colors; this will only generate colors with sufficient luma to be readable on a dark background... you may have to modify it for light export LC_NUMERIC="en_US.UTF-8" &> /dev/null #Fix for locales that use , instead of . as a decimal delimiter
randcolor() {
cluma=0 # Define "global" variables
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]]; environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
do version=1.1.2
cr=$((0 + $RANDOM % 255))
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
cg=$((0 + $RANDOM % 255))
cgl=$(echo "$cg 0.299" | awk '{print $1 * $2}')
cb=$((0 + $RANDOM % 255))
cbl=$(echo "$cb 0.299" | awk '{print $1 * $2}')
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
loops=$((loops+1))
done
echo "\e[38;2;${cr};${cg};${cb}m"
}
#========Welcome=======# #========Welcome=======#
welcome () { welcome () {
msg="Welcome" # Default
greetingsLength=${#greetings[@]}
greetingsNumber=$((RANDOM % greetingsLength))
if command -v whoami &>/dev/null ; then
usr=$(whoami)
elif command -v id &>/dev/null; then
usr=$(id -u -n)
else
usr=$USER
fi
if [ "$randgreeting" = "on" ]; then
msg=${greetings[@]:$greetingsNumber:1}
fi
# Print the welcome message # Print the welcome message
echo -en "Welcome, ${USRC}${BOLD}$USER${NCOL}. " echo -en "$msg, ${USRC}${BOLD}$usr${NCOL}. "
} }
#=========Time=========# #=========Time=========#
clock () { clock () {
bksp=""
# Set the current hour and minute # Set the current hour and minute
hour12=$(date +%I) if [ "$twelvehour" = "on" ]; then
if [[ "$(date +%_I)" -lt 10 ]]; then
hour="\b$(date +%_I)"
else
hour="$(date +%_I)"
fi
ampm=$(date +%p)
else
hour=$(date +%H)
bksp="\b \b" # This is a hack to fix some spacing issues with AM and PM with different lengths of time
fi
minute=$(date +%M) minute=$(date +%M)
# Print the time # Print the time
echo -en "The time is ${TIME}$hour12${BLNK}:${NCOL}${TIME}$minute${NCOL}. " echo -en "The time is ${TIME}$hour${BLNK}:${NCOL}${TIME}$minute $bksp${ampm}${NCOL}. "
} }
#=======Greeting=======# #=======Greeting=======#
greeting () { greeting () {
# Set the hour # Set the hour
hour=$(date +%H) hour=$(date +%H)
greet="It's"
if [ $hour -le 11 ] && [ $hour -gt 6 ]; if [ "$goodgreeting" = "on" ]; then
then greet="Good"
echo -en "It's ${MORN}morning${NCOL}. " fi
elif [ $hour -eq 12 ];
then # Change color and greeting depending on the segment of day
if [ "$hour" -le 11 ] && [ "$hour" -gt 6 ]; then
echo -en "$greet ${MORN}morning${NCOL}. "
elif [ "$hour" -eq 12 ]; then
echo -en "It's ${AFTN}noon${NCOL}. " echo -en "It's ${AFTN}noon${NCOL}. "
elif [ $hour -le 16 ] && [ $hour -gt 12 ]; elif [ "$hour" -le 17 ] && [ "$hour" -gt 12 ]; then
then echo -en "$greet ${AFTN}afternoon${NCOL}. "
echo -en "It's ${AFTN}afternoon${NCOL}. " elif [ "$hour" -le 19 ] && [ "$hour" -gt 17 ]; then
elif [ $hour -le 19 ] && [ $hour -gt 17 ]; echo -en "$greet ${EVEN}evening${NCOL}. "
then
echo -en "It's ${EVEN}evening${NCOL}. "
else else
echo -en "It's ${NIGH}night${NCOL}. " echo -en "It's ${NIGH}night${NCOL}. "
fi fi
@ -59,29 +77,28 @@ battery () {
# Set a default to prevent errors # Set a default to prevent errors
batlvl=0 batlvl=0
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]]; # Check the two usually used battery locations
then if [[ -a "/sys/class/power_supply/BAT0/capacity" ]]; then
batlvl=$(cat /sys/class/power_supply/BAT0/capacity) batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; then
then
batlvl=$(cat /sys/class/power_supply/BAT1/capacity) batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
elif command -v pmset &> /dev/null;then
batlvl=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
else
batlvl=-1
fi fi
# Change color depending on level # Change color depending on level
if [ $batlvl -eq 100 ]; if [[ $batlvl -ge 100 ]]; then
then
echo -en "The battery is ${FULL}fully charged${NCOL}. " echo -en "The battery is ${FULL}fully charged${NCOL}. "
else elif [[ $batlvl -gt 0 ]]; then
echo -en "The battery level is " echo -en "The battery level is "
if [ $batlvl -le 15 ]; if [[ $batlvl -le 15 ]]; then
then
echo -en "${CRIT}$batlvl%${NCOL}. " echo -en "${CRIT}$batlvl%${NCOL}. "
if [ "$rechargenotif" = "on" ]; if [[ "$rechargenotif" = "on" ]]; then
then
echo -en "- ${NORM}You should probably recharge${NCOL}. " echo -en "- ${NORM}You should probably recharge${NCOL}. "
fi fi
elif [ $batlvl -le 30 ]; elif [ $batlvl -le 30 ]; then
then
echo -en "${LOW}$batlvl%${NCOL}. " echo -en "${LOW}$batlvl%${NCOL}. "
else else
echo -en "${NORM}$batlvl%${NCOL}. " echo -en "${NORM}$batlvl%${NCOL}. "
@ -95,74 +112,130 @@ updates () {
debian=0 debian=0
arch=0 arch=0
fedora=0 fedora=0
brew=0
flatpak=0 flatpak=0
chk=0
updates=0
# Check for updates from different places... # Check for updates from different places... wonder if there's a better way
updchk () {
# Check for APT # Check for APT (Debian based)
if command -v apt &> /dev/null; if command -v apt-get &> /dev/null; then
then debian=$(apt-get -s dist-upgrade -V | grep -c '=>')
debian=$(apt-get -s dist-upgrade -V | grep '=>' | awk '{print$1}' | wc -l)
fi fi
# Check for different Arch things # Check for Arch things
if command -v yay &> /dev/null; if command -v checkupdates &> /dev/null; then
then arch=$(checkupdates 2> /dev/null | wc -l)
elif command -v yay &> /dev/null; then
arch=$(yay -Qu 2> /dev/null | wc -l) arch=$(yay -Qu 2> /dev/null | wc -l)
elif command -v paru &> /dev/null; elif command -v paru &> /dev/null; then
then
arch=$(paru -Quq 2> /dev/null | wc -l) arch=$(paru -Quq 2> /dev/null | wc -l)
elif command -v pacman &> /dev/null; elif command -v pacman &> /dev/null; then
then
arch=$(pacman -Qu 2> /dev/null | wc -l) arch=$(pacman -Qu 2> /dev/null | wc -l)
fi fi
# Check for Fedora things # Check for Fedora things
if command -v dnf &> /dev/null; if command -v dnf &> /dev/null; then
then
fedora=$(dnf list updates 2> /dev/null | wc -l) fedora=$(dnf list updates 2> /dev/null | wc -l)
fedora=$((fedora-1)) fedora=$((fedora-1))
elif command -v yum &> /dev/null; elif command -v yum &> /dev/null; then
then
fedora=$(yum list updates 2> /dev/null | wc -l) fedora=$(yum list updates 2> /dev/null | wc -l)
fedora=$((fedora-1)) fedora=$((fedora-1))
fi fi
# Check for OpenSUSE things
if command -v zypper &> /dev/null; then
suse=$(zypper list-updates 2> /dev/null | wc -l)
suse=$((suse-4))
fi
# Check for Brew updates
if command -v brew &> /dev/null; then
brew=$(brew outdated 2> /dev/null | wc -l)
fi
# Check for Flatpak # Check for Flatpak
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
then
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l) flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
fi fi
# Add all update counts together # Add all update counts together
updates=$(($debian + $arch + fedora + $flatpak)) updates=$((debian + arch + fedora + suse + flatpak + brew))
echo $updates >| ~/.welcome/updates
pkill -P "${pid}" sleep # When update checking is finished, kill the sleep function running under this bash process
sleep 5
if [[ -a ~/.welcome/updates ]]; then
rm ~/.welcome/updates
fi
}
pid=$$ # Grab the PID of the process
updchk & # Check for updates Asynchronously
set +e # Allow nonzero exit status for killing sleep
exec 3>&2 # These exec commands simply supress the output of the "kill" command
exec 2> /dev/null
sleep 5
chk=$?
exec 2>&3 # And then re-enable it
exec 3>&-
set -e # Return to disallowing nonzero exit status
if [[ -a ~/.welcome/updates ]]; then
updates=$(cat ~/.welcome/updates)
rm ~/.welcome/updates
fi
# Check the update amounts and print them out # Check the update amounts and print them out
if [ $updates -eq 1 ]; if [ $chk -lt 1 ]; then
then echo -en "Update check timed out. "
echo -en "You have ${NORM}1${NCOL} pending update. " else
elif [ $updates -eq 0 ]; if [ "${updates}" -eq 0 ]; then
then
echo -en "You have no pending updates. " echo -en "You have no pending updates. "
elif [ "${updates}" -eq 1 ]; then
echo -en "You have ${NORM}1${NCOL} pending update. "
else else
echo -en "You have ~${NORM}$updates${NCOL} pending updates. " echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
fi fi
fi
}
#=====Random Color=====#
randcolor() {
# For random colors; this will only generate colors with sufficient #
# perceptual luma to be readable on a dark background... you may have #
# to modify it for a light one #
cluma=0
loops=0
while [ "$(printf %.0f $cluma)" -le 100 ] && [ $loops -le 10 ]; do
cr=$((0 + RANDOM % 255))
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
cg=$((0 + RANDOM % 255))
cgl=$(echo "$cg 0.587" | awk '{print $1 * $2}')
cb=$((0 + RANDOM % 255))
cbl=$(echo "$cb 0.114" | awk '{print $1 * $2}')
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
loops=$((loops+1))
done
echo "\e[38;2;${cr};${cg};${cb}m"
} }
#=========COLORS=======# #=========COLORS=======#
# Set colors for ease of use
NCOL='\e[0m' NCOL='\e[0m'
CRIT='\e[31m'
LOW='\e[33m'
NORM='\e[32m'
FULL='\e[3;4;92m'
BOLD='\e[1m' BOLD='\e[1m'
ITAL='\e[3m' ITAL='\e[3m'
UNDR='\e[4m' UNDR='\e[4m'
BLNK='\e[5m' BLNK='\e[5m'
# Battery level colors
CRIT='\e[31m'
LOW='\e[33m'
NORM='\e[32m'
FULL='\e[3;4;92m'
TIME='\e[38;2;224;146;252;1m' # Clock color TIME='\e[38;2;224;146;252;1m' # Clock color
DATE='\e[38;2;50;168;82;1m'
USRC=$(randcolor) # <-----------Username color USRC=$(randcolor) # <-----------Username color
# Greeting colors # Greeting colors
@ -171,17 +244,40 @@ MORN='\e[38;2;255;164;74m'
AFTN='\e[38;2;250;245;110m' AFTN='\e[38;2;250;245;110m'
EVEN='\e[38;2;171;54;3m' EVEN='\e[38;2;171;54;3m'
#=========SETUP========# greetings=("Welcome" "Greetings" "Hello" "Hi") # Add your own greetings!
# Select which parts you want active by commenting them out randgreeting="off" #< Turn the random greetings on (eg. "Hello <user>, Hi <user>")
# For example, on a desktop, disabling the battery message is a good idea twelvehour="on" #< Switch between 12 and 24 hour time (eg. 8:00 PM vs 20:00)
# You can also re order them to change how they display! rechargenotif="off" #< Notify that you should recharge if below 15%
updatecheck="on" #< Check for general updates
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
flatpakupd="off" # Check for flatpak updates, this slows startup down A LOT # ALL the stuff above this line and below the colors line is in the config, changing it here will do nothing only if the config doesn't exist!
rechargenotif="off" # Notify that you should recharge if below 15%
source ~/.welcome/config.cfg
welcome welcome
greeting greeting
clock clock
battery battery
updates #< This makes startup slower if [ "$updatecheck" = "on" ]; then
updates
fi
echo # Properly line break at the end echo # Properly line break at the end
set +e
date=$(date +%s)
lastdate=$(cat ~/.welcome/udm 2>/dev/null)
if [[ $((date - lastdate)) -ge 86400 ]]; then
if [[ "$environment" = "bash" ]]; then
bash ~/.welcome/install.sh auto
elif [[ "$environment" = "zsh" ]]; then
zsh ~/.welcome/install.sh auto
fi
date +%s >| ~/.welcome/udm 2>/dev/null
elif ! [[ -f ~/.welcome/udm ]]; then
touch ~/.welcome/udm
date +%s >| ~/.welcome/udm 2>/dev/null
fi