Skip to content

Customizing bash‐showoff‐script

Conner Smith edited this page Sep 10, 2024 · 4 revisions

Customization

I want this script to be your own, so here's some documentation to help you understand how everything under the hood works. I have tried my best to make this script as modular and easy to setup as possible, so hopefully you can come up with some creative ways to customize it! Located at the top of the file are a number of variables to configure what happens on screen. If these variables aren't enough for your range of customization, you can add or remove features. Given that this is a bash script, it should be easy to look at the code and understand what's happening.

While it's not recommended, if what you're looking for is not here, you can edit /usr/bin/confetch_bin/start.sh. Keep in mind that this script will be overwritten with the next update. If that bothers you because you want to add a feature you think should be in it, please open an issue, and I'll do my best to add it!

Format

If you were to strip away all the fancy ASCII art, the output would look something like this:

$USER's $DEVICE
$DISTRO

$MODEL
$RAM OK
Hello, $USER.

$TODAY
$TIMENOW

(Contents of wttr.in/$CITY?$WTROPTIONS | Contents of wttr.in/moon?$MOONOPTIONS)

Variables

USERGRAB:

## --- Username Selection ---
## Grabs your username from Bash $USER variable
## Example UNIX username: conner
## Select 1 to capitalize the first letter. Output: Conner
## Select 2 to keep the username as it is. Output: conner
## Add quotation marks to manually specify a name. Output: HamBurger
USERGRAB=1

Usergrab defines how the username will be displayed. There are three options, 1, 2, or a string. The binary options grab your username from UNIX and pop them into the script. If you pass a 2, it will be copied directly from UNIX, however if you pass a 1, it will capitalize the first letter (useful for people who use their name as their username). Alternatively, if you set the variable to a string, whatever you set $USERGRAB to will be what shows up on the script. So, if I passed USERGRAB="HamBurger", I would get this:

(baaaaar) HamBurger's $DEVICE
(baaaar) $DISTRO
(baaar)
(baar) $MODEL
(bar) $RAM OK

DEVICE:

DEVICE="Laptop"

Sets the name of the device that follows your username. With the above two examples I'd get HamBurger's Laptop. Typically I put how I would describe the device in one word (PC, Tablet, Laptop, Pi, Server, etc). I don't recommend trying to put your device model (unless you want to nix the model that shows on the 3rd line and have it show up next to your name, that's cool too), as that's what $MODEL is for.

DISTRO

DISTRO="Ubuntu Linux"

Sets the name of the distro that shows up on the second line. Right now the script doesn't automatically grab the distro (although I do plan on adding that in the future), so for now you can simply specify manually.

MODEL

MODEL="Dell Latitude 7940"

Sets the name of the device model on the third line. This is supposed to represent your device model. Examples:

MODEL="Dell Latitude 7940"
MODEL="Nintendo Switch OLED"
# Remember to use a \ to escape quotation marks, otherwise you'll get an error 
MODEL="MacBook Pro 13\" (M1)"
MODEL="Custom PC"
MODEL="Raspberry Pi 5"
MODEl=true # Grabs your model info via `cat /sys/devices/virtual/dmi/id/product_name`

...and so on

WTROPTIONS

WTROPTIONS="2FnQ"

These are the operands passed to wttr.in when retrieving the weather. Refer to wttr.in's help page for a full list of operands. The one I use is 2FnQ. Remember, the operands are case-sensitive.

2- Current weather + today and tomorrow's forecast F- Hides the "Follow igor_chubin for updates" line at the bottom (Sorry, igor!) n- Narrow version (Only day and night) Q- Superquiet, hides the "Weather report" and "City" lines

MOONOPTIONS

MOONOPTIONS="F"

Same as above, but for the moon. I only use F, but you can use any operands that are applicable to the moon page.

skip_curl_check

This only applies to the bash script version. Packaged versions will install curl with the package.

skip_curl_check=false

This script that has a function that checks to see if curl is installed, and if not attempts to install it via apt-get, yum, dnf, pacman, or brew. The system goes down that list in order to see which package manager you use if it detects curl is not installed. If the program is unable to detect your package manager, it aborts trying to grab wttr.in info. If you have curl installed but are failing the check, switch skip_curl_check to false to run curl regardless.

WTRSIDE

WTRSIDE=true

When true, this displays the weather report and moon phase side-by-side via the paste command. If you'd like to show the moon phase under the weather report instead, set this variable to false.

RAM

Automatically grab the amount of megabytes of RAM. If you'd like to lie-- I mean manually specify the amount of RAM, change true to your value.

RAM=$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"M"
RAM="32036M"

By default, $RAM gets its value by using getconf to get the number of pages, then multiplies that by the size of a page in bytes. Then it divides that number by 1024 to the power of 2 to convert it from bytes to megabytes. Alternatively, if you want to input a nice clean number, the getconf command returns an incorrect value, or you just want to lie about your RAM (I get it ;)), you can comment out that line and uncomment the RAM=32036M line, and replace the value with whatever you want.

CITY

This only applies to the bash script version. The packaged version handles this during the first time consent screen.

CITY="Dallas"

Sets your city for wttr.in.

ANIMATE

ANIMATE=true

Sets if you want it to run through the color bar animation or not. If true, it draws one "frame", sleeps for $SLEEP seconds (see below), then draws the next one until it has drawn everything. If not, it simply clears the terminal and draws the color bars and info text all in one frame.

SLEEP

SLEEP=0.05

Sleeps for x amount of seconds before moving to the next frame if $ANIMATE is turned on. I like using 0.05 seconds (50 ms) as it looks nice.

wtr_path & moon_path

This only applies to the bash script version. Packaged versions store it in your ~/.config/confetch directory.

# Path to where you want to keep the wtr and moon files
wtr_path="/home/conner/.scripts/wtr"
moon_path="/home/conner/.scripts/moon"

As the bash comment above might suggest, this is where the file that stores the data from wttr.in is located. If the file does not exist, it will create it when it goes to download from wttr.in. I recommend passing the full path so it will function properly regardless of what directory you execute the script from.

TODAY and TIMENOW

TODAY=$(date +"Today's date is %A, %B %d %Y.")
TIMENOW=$(date +"The local time is %r")

These variables grab todays date and time using the date command. To change what displays, change the date variables.

hidecity

If hidecity=false, this is the output you get:

Here's the weather in Plano (As of 7 hours ago):

If hidecity=true, this is the output you get:

Here's the weather (As of 7 hours ago):

Running other commands

Running other commands is easy! Simply edit ~/.config/confetch/commands.txt and pop in any commands you want to run after the weather info.