Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show your edits in rxfetch #21

Open
mngshm opened this issue Jul 27, 2021 · 20 comments
Open

Show your edits in rxfetch #21

mngshm opened this issue Jul 27, 2021 · 20 comments

Comments

@mngshm
Copy link
Owner

mngshm commented Jul 27, 2021

This issue is created for posting/sharing the configs and screenshots for a custom script of rxfetch. This issue is open for everyone to upload there stuff.

@nihsx
Copy link
Contributor

nihsx commented Feb 26, 2022

My custom script rxfetch for Termux , you can find my custom script here

rxfetch

@nwvh
Copy link

nwvh commented May 21, 2022

I edited the mayTermux's config to work on desktops haha

image

https://github.com/WooxHimself/rxfetch-stylish

@drawblank
Copy link

Got rxfetch working on MacOS (mostly)
image
Unfortunately, the pacman icons will have to wait until I can figure out how to add them in.
I also added a somewhat good port of the free command from Linux as a small bash function. I then made $os a global variable to minimise reusing.
The only other thing missing is the Apple logo in place of Tux.
A small problem is that getting the number of packages from homebrew is quite slow.

Here's the code:

#!/usr/bin/env bash

#colors
#bold="(tput bold)"
magenta="\033[1;35m"
green="\033[1;32m"
white="\033[1;37m"
blue="\033[1;34m"
red="\033[1;31m"
black="\033[1;40;30m"
yellow="\033[1;33m"
cyan="\033[1;36m"
reset="\033[0m"
bgyellow="\033[1;43;33m"
bgwhite="\033[1;47;37m"
c0=${reset}
c1=${magenta}
c2=${green}
c3=${white}
c4=${blue}
c5=${red}
c6=${yellow}
c7=${cyan}
c8=${black}
c9=${bgyellow}
c10=${bgwhite}

os=$(uname -s)

# Setup fonts
setup_fonts() {
	if [ "$os" != Android ]; then
		if ! fc-match :family='Material' | grep -Eq '^Material.ttf'; then
			mkdir -p "$HOME/.local/share/fonts"
			cp ttf-material-design-icons/* "$HOME/.local/share/fonts"
			fc-cache -vf &>/dev/null
		fi
	fi
}

# Get the init
get_init() {
	if [ "$os" = "Android" ]; then
		echo 'init.rc'
	elif [ "$os" = "Darwin" ]; then
		echo 'launchd'
	elif pidof -q systemd; then
		echo 'systemd'
	elif [ -f '/sbin/openrc' ]; then
		echo 'openrc'
	else
		cut -d ' ' -f 1 /proc/1/comm
	fi
}

# Get count of packages installed
get_pkg_count() {
	package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge')
	for package_manager in "${package_managers[@]}"; do
		if command -v "$package_manager" 2>/dev/null >&2; then
			case "$package_manager" in
			xbps-install) xbps-query -l | wc -l ;;
			apk) apk search | wc -l ;;
			apt) echo $(($(apt list --installed 2>/dev/null | wc -l) - 1)) ;;
			pacman) pacman -Q | wc -l ;;
			nix) nix-env -qa --installed '*' | wc -l ;;
			dnf) dnf list installed | wc -l ;;
			rpm) rpm -qa | wc -l ;;
			emerge) qlist -I | wc -l ;;
			esac

			# if a package manager is found return from the function
			return
		fi
	done
	echo 0
}

# Get count of snaps installed
get_snap_count() {
	if command -v snap 2>/dev/null >&2; then
		count=$(snap list | wc -l)

		# snap list shows a header line
		echo $((count - 1))

		return
	fi

	echo 0
}

# Get count of flatpaks installed
get_flatpak_count() {
	if command -v flatpak 2>/dev/null >&2; then
		flatpak list | wc -l
		return
	fi

	echo 0
}

# Get package information formatted
get_package_info() {
	if [[ $(which -s brew) != "brew not found" ]] ; then
		echo "$(brew list -1 --formulae | wc -l) + $(brew list -1 --cask | wc -l)" | bc
		return
	fi

	pkg_count=$(get_pkg_count)
	snap_count=$(get_snap_count)
	flatpak_count=$(get_flatpak_count)

	if [ "$pkg_count" -ne 0 ]; then
		echo -n "$pkg_count"
		if [ "$snap_count" -ne 0 ]; then
			echo -n " ($snap_count snaps"
			if [ "$flatpak_count" -ne 0 ]; then
				echo ", $flatpak_count flatpaks)"
			else
				echo ")"
			fi
		elif [ "$flatpak_count" -ne 0 ]; then
			echo " ($flatpak_count flatpaks)"
		else
			echo ""
		fi
	elif [ "$snap_count" -ne 0 ]; then
		echo -n "$snap_count snaps"

		if [ "$flatpak_count" -ne 0 ]; then
			echo ", $flatpak_count flatpaks"
		else
			echo ""
		fi
	elif [ "$flatpak_count" -ne 0 ]; then
		echo "$flatpak_count flatpaks"
	else
		echo "Unknown"
	fi
}

# Get distro name
get_distro_name() {
	if [ "$os" = "Android" ]; then
		echo 'Android'
	elif [ "$os" = "Darwin" ]; then
		echo "MacOS" $(sw_vers -productVersion)
	else
		awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release
	fi
}

# Get root partition space used
get_storage_info() {
	if [ "$os" = Android ]; then
		_MOUNTED_ON="/data"
		_GREP_ONE_ROW="$(df -h | grep ${_MOUNTED_ON})"
		_SIZE="$(echo "${_GREP_ONE_ROW}" | awk '{print $2}')"
		_USED="$(echo "${_GREP_ONE_ROW}" | awk '{print $3}')"
		echo "$(head -n1 <<<"${_USED}")B / $(head -n1 <<<"${_SIZE}")B"
	elif [ "$os" = "Darwin" ]; then
		df -h | head -n 2 | tail -n 1 | awk '{ print $3" / "$2 }'
	else
		df -h --output=used,size / | awk 'NR == 2 { print $1" / "$2 }'
	fi
}

free_command_mac() {
	_TOTALMEM=$(echo "$(sysctl hw.memsize | awk '{print $2}') / 1024 / 1024" | bc)
	_FREEMEM=$(echo "$(vm_stat | head -n 1 | awk '{print $8}') * $(vm_stat | head -n 2 | tail -n 1 |  awk '{print $3}' | sed 's/[^0-9]*//g') / 1024 / 1024" | bc)
	_USEDMEM=$(echo "$_TOTALMEM - $_FREEMEM" | bc)
	_TOTALSWAP=$(echo "$(sysctl vm.swapusage | awk '{print $4}' | sed 's/[^0-9\.]*//g') * 1024" | bc)
	_USEDSWAP=$(echo "$(sysctl vm.swapusage | awk '{print $7}' | sed 's/[^0-9\.]*//g') * 1024" | bc)
	_FREESWAP=$(echo "$(sysctl vm.swapusage | awk '{print $10}' | sed 's/[^0-9\.]*//g') * 1024" | bc)
	if [ $(sysctl vm.swapusage | awk '{print $11}') > /dev/null ]; then
		_ENCRYPT=$(sysctl vm.swapusage | awk '{print $11}')
	fi
	printf "   $(printf "XXX: total used free\nMem: $_TOTALMEM $_USEDMEM $_FREEMEM\nNULL\nSwap: $_TOTALSWAP $_USEDSWAP $_FREESWAP $_ENCRYPT\n" | column -t | sed -e '1!b' -e 's/^[^:]*:/ /g')\n"
}

# Get Memory usage
get_mem() {
	if [ "$os" = "Darwin" ]; then
		echo $(free_command_mac | awk 'NR == 2 { print $3" / "$2" MB" }')
	else
		echo $(free --mega | awk 'NR == 2 { print $3" / "$2" MB" }')
	fi
}

# Get uptime
get_uptime() {
	if [ "$os" = "Darwin" ]; then
		uptime | sed 's/.*up//' | sed 's/, load averages: .*//'
	else
		uptime -p | sed 's/up//'
	fi
}

# Get DE/WM
# Reference: https://github.com/unixporn/robbb/blob/master/fetcher.sh
get_de_wm() {
	if [ "$os" = "Darwin" ]; then
		echo "Default"
	else
		wm="${XDG_CURRENT_DESKTOP#*:}"
		[ "$wm" ] || wm="$DESKTOP_SESSION"

		# for most WMs
		[ ! "$wm" ] && [ "$DISPLAY" ] && command -v xprop >/dev/null && {
			id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK 2>/dev/null)
			id=${id##* }
			wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t 2>/dev/null | grep '^_NET_WM_NAME' | cut -d\" -f 2)
		}

		# for non-EWMH WMs
		[ ! "$wm" ] || [ "$wm" = "LG3D" ] &&
			wm=$(pgrep -m 1 -o \
				-e "sway" \
				-e "kiwmi" \
				-e "wayfire" \
				-e "sowm" \
				-e "catwm" \
				-e "fvwm" \
				-e "dwm" \
				-e "2bwm" \
				-e "monsterwm" \
				-e "tinywm" \
				-e "xmonad")

		echo "${wm:-unknown}"
	fi
}

setup_fonts

echo "               "

if [ "$os" = Android ]; then
	echo -e "               ${c5}phone${c3}  $(getprop ro.product.brand) $(getprop ro.product.model)"
fi

echo -e "               ${c1}os${c3}     $(get_distro_name) $(uname -m)"
echo -e "               ${c2}ker${c3}    $(uname -r)"
echo -e "     ${c3}${c8}_${c3}${c0}       ${c7}pkgs${c3}   $(get_package_info)"
echo -e "     ${c8}${c0}${c9}oo${c0}${c8}|${c0}       ${c4}sh${c3}     ${SHELL##*/}"
echo -e "    ${c8}/${c0}${c10}${c0}${c8}'\'${c0}      ${c6}ram${c3}    $(get_mem)"
echo -e "   ${c9}(${c0}${c8}\_;/${c0}${c9})${c0}      ${c1}init${c3}   $(get_init)"

if [ -n "$DISPLAY" ]; then
	echo -e "               ${c2}de/wm${c3}  $(get_de_wm)"
fi

echo -e "               ${c7}up${c3}    $(get_uptime)"
echo -e "               ${c6}disk${c3}   $(get_storage_info)"
echo -e "               "

if [ "$os" != Android ]; then
	echo -e "        ${c6}󰮯  ${c6}${c2}󰊠  ${c2}${c4}󰊠  ${c4}${c5}󰊠  ${c5}${c7}󰊠  ${c7}"
fi

echo -e "               \033[0m"

@mngshm
Copy link
Owner Author

mngshm commented Jun 1, 2022

Nice work 👍 might add it to the official repo after you successfully get those pacman and ghosts working.

@drawblank
Copy link

Turns out that Nerd Fonts does not have the Pacman icon at all, and the Material Design Icon fonts are broken on MacOS. So, there's three possible options:

  1. Replace the icons with some other icons
  2. Replace the icons with images and use an image protocol like sixel or iTerm2's image protocol
  3. Wait for Nerd Fonts to update or for a substitute to be released

@mngshm
Copy link
Owner Author

mngshm commented Jun 1, 2022

Uhmm you can add a request for Pacman icon. ig they're accepting requests.

@DakshG07
Copy link

You could also just make your own font, if you felt like it.

@mngshm
Copy link
Owner Author

mngshm commented Jun 28, 2022

I have no idea how to do that? Do you know a way I can do that?

@nwvh
Copy link

nwvh commented Jun 28, 2022

I have no idea how to do that? Do you know a way I can do that?

Fontforge or other font designers/editor apps

@justleoo
Copy link

yo, i make a edit of a edit of a edit lmfao
image

@ghost
Copy link

ghost commented Oct 8, 2022

yo, i make a edit of a edit of a edit lmfao image

that looks really cool actually and im on void too, can you link that config 👀

@ghost
Copy link

ghost commented Oct 8, 2022

oh nevermind, i figured out how to do it, it's basically the config nwvh made. sorry for the reply!

@mngshm
Copy link
Owner Author

mngshm commented Oct 9, 2022

and unfortunately i came out of the void

@mngshm
Copy link
Owner Author

mngshm commented Oct 9, 2022

@13-05 https://github.com/mayTermux/rxfetch-termux this is the config

@ignacek1
Copy link

ignacek1 commented Jun 17, 2023

Replaced package count with the terminal because it took kinda long to load for me:

I also added an installation script
Code:
https://github.com/ignxcy/rxfetch

@0n1cOn3
Copy link
Contributor

0n1cOn3 commented Dec 18, 2023

Got rxfetch working on MacOS (mostly)

image

Unfortunately, the pacman icons will have to wait until I can figure out how to add them in.

I also added a somewhat good port of the free command from Linux as a small bash function. I then made $os a global variable to minimise reusing.

The only other thing missing is the Apple logo in place of Tux.

A small problem is that getting the number of packages from homebrew is quite slow.

Here's the code:

#!/usr/bin/env bash



#colors

#bold="(tput bold)"

magenta="\033[1;35m"

green="\033[1;32m"

white="\033[1;37m"

blue="\033[1;34m"

red="\033[1;31m"

black="\033[1;40;30m"

yellow="\033[1;33m"

cyan="\033[1;36m"

reset="\033[0m"

bgyellow="\033[1;43;33m"

bgwhite="\033[1;47;37m"

c0=${reset}

c1=${magenta}

c2=${green}

c3=${white}

c4=${blue}

c5=${red}

c6=${yellow}

c7=${cyan}

c8=${black}

c9=${bgyellow}

c10=${bgwhite}



os=$(uname -s)



# Setup fonts

setup_fonts() {

	if [ "$os" != Android ]; then

		if ! fc-match :family='Material' | grep -Eq '^Material.ttf'; then

			mkdir -p "$HOME/.local/share/fonts"

			cp ttf-material-design-icons/* "$HOME/.local/share/fonts"

			fc-cache -vf &>/dev/null

		fi

	fi

}



# Get the init

get_init() {

	if [ "$os" = "Android" ]; then

		echo 'init.rc'

	elif [ "$os" = "Darwin" ]; then

		echo 'launchd'

	elif pidof -q systemd; then

		echo 'systemd'

	elif [ -f '/sbin/openrc' ]; then

		echo 'openrc'

	else

		cut -d ' ' -f 1 /proc/1/comm

	fi

}



# Get count of packages installed

get_pkg_count() {

	package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge')

	for package_manager in "${package_managers[@]}"; do

		if command -v "$package_manager" 2>/dev/null >&2; then

			case "$package_manager" in

			xbps-install) xbps-query -l | wc -l ;;

			apk) apk search | wc -l ;;

			apt) echo $(($(apt list --installed 2>/dev/null | wc -l) - 1)) ;;

			pacman) pacman -Q | wc -l ;;

			nix) nix-env -qa --installed '*' | wc -l ;;

			dnf) dnf list installed | wc -l ;;

			rpm) rpm -qa | wc -l ;;

			emerge) qlist -I | wc -l ;;

			esac



			# if a package manager is found return from the function

			return

		fi

	done

	echo 0

}



# Get count of snaps installed

get_snap_count() {

	if command -v snap 2>/dev/null >&2; then

		count=$(snap list | wc -l)



		# snap list shows a header line

		echo $((count - 1))



		return

	fi



	echo 0

}



# Get count of flatpaks installed

get_flatpak_count() {

	if command -v flatpak 2>/dev/null >&2; then

		flatpak list | wc -l

		return

	fi



	echo 0

}



# Get package information formatted

get_package_info() {

	if [[ $(which -s brew) != "brew not found" ]] ; then

		echo "$(brew list -1 --formulae | wc -l) + $(brew list -1 --cask | wc -l)" | bc

		return

	fi



	pkg_count=$(get_pkg_count)

	snap_count=$(get_snap_count)

	flatpak_count=$(get_flatpak_count)



	if [ "$pkg_count" -ne 0 ]; then

		echo -n "$pkg_count"

		if [ "$snap_count" -ne 0 ]; then

			echo -n " ($snap_count snaps"

			if [ "$flatpak_count" -ne 0 ]; then

				echo ", $flatpak_count flatpaks)"

			else

				echo ")"

			fi

		elif [ "$flatpak_count" -ne 0 ]; then

			echo " ($flatpak_count flatpaks)"

		else

			echo ""

		fi

	elif [ "$snap_count" -ne 0 ]; then

		echo -n "$snap_count snaps"



		if [ "$flatpak_count" -ne 0 ]; then

			echo ", $flatpak_count flatpaks"

		else

			echo ""

		fi

	elif [ "$flatpak_count" -ne 0 ]; then

		echo "$flatpak_count flatpaks"

	else

		echo "Unknown"

	fi

}



# Get distro name

get_distro_name() {

	if [ "$os" = "Android" ]; then

		echo 'Android'

	elif [ "$os" = "Darwin" ]; then

		echo "MacOS" $(sw_vers -productVersion)

	else

		awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release

	fi

}



# Get root partition space used

get_storage_info() {

	if [ "$os" = Android ]; then

		_MOUNTED_ON="/data"

		_GREP_ONE_ROW="$(df -h | grep ${_MOUNTED_ON})"

		_SIZE="$(echo "${_GREP_ONE_ROW}" | awk '{print $2}')"

		_USED="$(echo "${_GREP_ONE_ROW}" | awk '{print $3}')"

		echo "$(head -n1 <<<"${_USED}")B / $(head -n1 <<<"${_SIZE}")B"

	elif [ "$os" = "Darwin" ]; then

		df -h | head -n 2 | tail -n 1 | awk '{ print $3" / "$2 }'

	else

		df -h --output=used,size / | awk 'NR == 2 { print $1" / "$2 }'

	fi

}



free_command_mac() {

	_TOTALMEM=$(echo "$(sysctl hw.memsize | awk '{print $2}') / 1024 / 1024" | bc)

	_FREEMEM=$(echo "$(vm_stat | head -n 1 | awk '{print $8}') * $(vm_stat | head -n 2 | tail -n 1 |  awk '{print $3}' | sed 's/[^0-9]*//g') / 1024 / 1024" | bc)

	_USEDMEM=$(echo "$_TOTALMEM - $_FREEMEM" | bc)

	_TOTALSWAP=$(echo "$(sysctl vm.swapusage | awk '{print $4}' | sed 's/[^0-9\.]*//g') * 1024" | bc)

	_USEDSWAP=$(echo "$(sysctl vm.swapusage | awk '{print $7}' | sed 's/[^0-9\.]*//g') * 1024" | bc)

	_FREESWAP=$(echo "$(sysctl vm.swapusage | awk '{print $10}' | sed 's/[^0-9\.]*//g') * 1024" | bc)

	if [ $(sysctl vm.swapusage | awk '{print $11}') > /dev/null ]; then

		_ENCRYPT=$(sysctl vm.swapusage | awk '{print $11}')

	fi

	printf "   $(printf "XXX: total used free\nMem: $_TOTALMEM $_USEDMEM $_FREEMEM\nNULL\nSwap: $_TOTALSWAP $_USEDSWAP $_FREESWAP $_ENCRYPT\n" | column -t | sed -e '1!b' -e 's/^[^:]*:/ /g')\n"

}



# Get Memory usage

get_mem() {

	if [ "$os" = "Darwin" ]; then

		echo $(free_command_mac | awk 'NR == 2 { print $3" / "$2" MB" }')

	else

		echo $(free --mega | awk 'NR == 2 { print $3" / "$2" MB" }')

	fi

}



# Get uptime

get_uptime() {

	if [ "$os" = "Darwin" ]; then

		uptime | sed 's/.*up//' | sed 's/, load averages: .*//'

	else

		uptime -p | sed 's/up//'

	fi

}



# Get DE/WM

# Reference: https://github.com/unixporn/robbb/blob/master/fetcher.sh

get_de_wm() {

	if [ "$os" = "Darwin" ]; then

		echo "Default"

	else

		wm="${XDG_CURRENT_DESKTOP#*:}"

		[ "$wm" ] || wm="$DESKTOP_SESSION"



		# for most WMs

		[ ! "$wm" ] && [ "$DISPLAY" ] && command -v xprop >/dev/null && {

			id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK 2>/dev/null)

			id=${id##* }

			wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t 2>/dev/null | grep '^_NET_WM_NAME' | cut -d\" -f 2)

		}



		# for non-EWMH WMs

		[ ! "$wm" ] || [ "$wm" = "LG3D" ] &&

			wm=$(pgrep -m 1 -o \

				-e "sway" \

				-e "kiwmi" \

				-e "wayfire" \

				-e "sowm" \

				-e "catwm" \

				-e "fvwm" \

				-e "dwm" \

				-e "2bwm" \

				-e "monsterwm" \

				-e "tinywm" \

				-e "xmonad")



		echo "${wm:-unknown}"

	fi

}



setup_fonts



echo "               "



if [ "$os" = Android ]; then

	echo -e "               ${c5}phone${c3}  $(getprop ro.product.brand) $(getprop ro.product.model)"

fi



echo -e "               ${c1}os${c3}     $(get_distro_name) $(uname -m)"

echo -e "               ${c2}ker${c3}    $(uname -r)"

echo -e "     ${c3}${c8}_${c3}${c0}       ${c7}pkgs${c3}   $(get_package_info)"

echo -e "     ${c8}${c0}${c9}oo${c0}${c8}|${c0}       ${c4}sh${c3}     ${SHELL##*/}"

echo -e "    ${c8}/${c0}${c10}${c0}${c8}'\'${c0}      ${c6}ram${c3}    $(get_mem)"

echo -e "   ${c9}(${c0}${c8}\_;/${c0}${c9})${c0}      ${c1}init${c3}   $(get_init)"



if [ -n "$DISPLAY" ]; then

	echo -e "               ${c2}de/wm${c3}  $(get_de_wm)"

fi



echo -e "               ${c7}up${c3}    $(get_uptime)"

echo -e "               ${c6}disk${c3}   $(get_storage_info)"

echo -e "               "



if [ "$os" != Android ]; then

	echo -e "        ${c6}󰮯  ${c6}${c2}󰊠  ${c2}${c4}󰊠  ${c4}${c5}󰊠  ${c5}${c7}󰊠  ${c7}"

fi



echo -e "               \033[0m"

Good work.
You said that brew packages take a long time?
I don't see a brew query in the script. Could be because of that.

@proffapt
Copy link
Collaborator

proffapt commented Dec 18, 2023

@0n1cOn3 https://github.com/Mangeshrex/rxfetch/blob/0a8b2c6dd01f221b66a25a1ae6bed3249d7c4e3d/rxfetch#L116

It's not the commented one but my variant

@0n1cOn3
Copy link
Contributor

0n1cOn3 commented Dec 18, 2023

@0n1cOn3

https://github.com/Mangeshrex/rxfetch/blob/0a8b2c6dd01f221b66a25a1ae6bed3249d7c4e3d/rxfetch#L116

It's not the commented one but my variant

When adding this into an PR 👍🏻 :D

@proffapt
Copy link
Collaborator

@0n1cOn3
https://github.com/Mangeshrex/rxfetch/blob/0a8b2c6dd01f221b66a25a1ae6bed3249d7c4e3d/rxfetch#L116

It's not the commented one but my variant

When adding this into an PR 👍🏻 :D

This already exists in the main branch XD

@0n1cOn3
Copy link
Contributor

0n1cOn3 commented Dec 19, 2023

@0n1cOn3

https://github.com/Mangeshrex/rxfetch/blob/0a8b2c6dd01f221b66a25a1ae6bed3249d7c4e3d/rxfetch#L116

It's not the commented one but my variant

When adding this into an PR 👍🏻 :D

This already exists in the main branch XD

I should probably read more often the source code 🙄😂 whoopsi 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants