#!/bin/bash

#; ______________
#; |  \o| . ||__   dfetch (dabble fetch) a simple system information tool
#; |__/||_|_| __|  https://github.com/diws1/dfetch
#;


# List of command
name=$(whoami)
os=$(source /etc/os-release && echo $PRETTY_NAME)
        #get shortname
        os_shortname=$(source /etc/os-release && echo $PRETTY_NAME | awk '{print$1}')
        #some distro names are in the second word ex: Linux Mint, Linux Lite
        os_shortname2=$(source /etc/os-release && echo $PRETTY_NAME | awk '{print$2}')
kernel=$(uname -sr)
shell=$(basename $SHELL)
uptime=$(uptime -p | sed 's/up //')
wm=$(echo $DESKTOP_SESSION)
mem=$(free -h | awk 'NR==2{print $3}' | sed s/i//)
#free=$(free -h | awk 'NR==2{print $4}' | sed s/i//)

# Add colors
#normal
bla=$(tput setaf 0)
red=$(tput setaf 1)
gre=$(tput setaf 2)
yel=$(tput setaf 3)
blu=$(tput setaf 4)
mag=$(tput setaf 5)
cya=$(tput setaf 6)
whi=$(tput setaf 7)
#bright
bbla=$(tput setaf 8)
bred=$(tput setaf 9)
bgre=$(tput setaf 10)
byel=$(tput setaf 11)
bblu=$(tput setaf 12)
bmag=$(tput setaf 13)
bcya=$(tput setaf 14)
bwhi=$(tput setaf 15)

# Text styling (bold, reset)
bld=$(tput bold)
rst=$(tput sgr0)

# Text position (default x, default y etc)
defpos_y=$(tput cuu 8)
defpos_x=$(tput cuf 23)
pos_x=$(tput cuf 19)

# Ascii image settings
#add ascii image folder
export PATH="${PATH}:/usr/bin/dfetch_logo"

#sett the ascii image
if [ $os_shortname = Debian ]; then
        asc="$(debian_logo)"
        pad="$pos_x"

elif [ $os_shortname = Arch ]; then
        asc="$(arch_logo)"
        pad="$pos_x"

elif [ $os_shortname = Void ]; then
        asc="$(void_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Ubuntu ]; then
        asc="$(ubuntu_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Fedora ]; then
        asc="$(fedora_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Manjaro ]; then
        asc="$(manjaro_logo)"
        pad="$pos_x"

elif [ $os_shortname = openSUSE ]; then
        asc="$(opensuse_logo)"
        pad="$pos_x"

elif [ $os_shortname = NixOS ]; then
        asc="$(nixos_logo)"
        pad="$pos_x"

elif [ $os_shortname = Gentoo ]; then
        asc="$(gentoo_logo)"
        pad="$pos_x"

elif [ $os_shortname2 = Mint ]; then
        asc="$(mint_logo)"
        pad="$defpos_x"

elif [ $os_shortname = LMDE ]; then
        asc="$(mint_logo)"
        pad="$defpos_x"

elif [ $os_shortname = EndeavourOS ]; then
        asc="$(endeavour_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Slackware ]; then
        asc="$(slackware_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Alpine ]; then
        asc="$(alpine_logo)"
        pad="$defpos_x"

elif [ $os_shortname = Kali ]; then
        asc="$(kali_logo2)"
        pad="$defpos_x"

elif [ $os_shortname = Artix ]; then
        asc="$(artix_logo)"
        pad="$pos_x"

elif [ $os_shortname = Solus ]; then
        asc="$(solus_logo)"
        pad="$pos_x"

elif [ $os_shortname = CRUX ]; then
        asc="$(crux_logo)"
        pad="$pos_x"

else
        asc="$(default_logo)"
        pad="$defpos_x"

fi

# Print result
cat <<EOF
$asc$defpos_y
$pad$blu$bld usr $rst $name
$pad$gre$bld dis $rst $os
$pad$mag$bld knl $rst $kernel
$pad$whi$bld sh  $rst $shell
$pad$red$bld up  $rst $uptime
$pad$cya$bld wm  $rst $wm
$pad$yel$bld mem $rst $mem

EOF

