Topic: My "FetchScreen" script
Recently I made a script like screenfetch or arckey but It's colorable ![]()
#!/bin/zsh
# Script by SuNjACk
# Only for SuNjACk (muahahah! :D)
# Version: 0.2
# GPL License (do what do you what)
# --////////////////////////--
# --// Identify The Infos //--
# --////////////////////////--
# The GTK settings
gtkrc="$HOME/.gtkrc-2.0"
GtkTheme=$( grep "gtk-theme-name" "$gtkrc" | cut -d\" -f2 )
GtkIcon=$( grep "gtk-icon-theme-name" "$gtkrc" | cut -d\" -f2 )
GtkFont=$( grep "gtk-font-name" "$gtkrc" | cut -d\" -f2 )
# The Wallpaper set with nitrogen
nitroconf="$HOME/.config/nitrogen/bg-saved.cfg"
Wallpaper="$( basename $(grep file $nitroconf | cut -d\= -f2 ))"
# Settings from ~/.Xdefaults
xdef="~/.Xdefaults"
TermFont="$(grep 'urxvt\*font' ~/.Xdefaults | cut -d\: -f2- | sed -re 's/xft://g; s/:size=(.*):.*/ \1/g; s/^ *//g')"
# Time and date
time=$( date "+%H.%M")
date=$( date "+%a %d %b" )
# OS
OS=$(cat /etc/issue | sed 's/\\.//g')
# WM version
AwVer=$( awesome --version | head -1 | cut -d' ' -f2 | sed 's/debian\///g' )
# --//////////////////////////////--
# --// Color for the higllights //--
# --//////////////////////////////--
cat-highlights-color () {
# col=$( echo $1 | sed 's/-c//g' )
col=${1#-c}
case $col in
0) export H='\e[30m';;
1) export H='\e[31m';;
2) export H='\e[32m';;
3) export H='\e[33m';;
4) export H='\e[34m';;
5) export H='\e[35m';;
6) export H='\e[36m';;
7) export H='\e[37m';;
8) export H='\e[1;30m';;
9) export H='\e[1;31m';;
10) export H='\e[1;32m';;
11) export H='\e[1;33m';;
12) export H='\e[1;34m';;
13) export H='\e[1;35m';;
14) export H='\e[1;36m';;
15) export H='\e[1;37m';;
esac
}
# --////////////////////////--
# --// Color for the logo //--
# --////////////////////////--
cat-logo-color () {
# col=$( echo $1 | sed 's/-C//g' )
col=${1#-C}
case $col in
0) export L='\e[30m';;
1) export L='\e[31m';;
2) export L='\e[32m';;
3) export L='\e[33m';;
4) export L='\e[34m';;
5) export L='\e[35m';;
6) export L='\e[36m';;
7) export L='\e[37m';;
8) export L='\e[1;30m';;
9) export L='\e[1;31m';;
10) export L='\e[1;32m';;
11) export L='\e[1;33m';;
12) export L='\e[1;34m';;
13) export L='\e[1;35m';;
14) export L='\e[1;36m';;
15) export L='\e[1;37m';;
esac
}
# --//////////////////////////////--
# --// Different Distros' Logos //--
# --//////////////////////////////--
# null color
NC='\e[0m'
# --// Debian Logo //--
logo-debian () {
test "$L" || L='\e[;31m'
test "$H" || H='\e[1;34m'
echo -e "
$L _,edm88888on.$NC
$L ,d888888888888888P.$NC
$L ,g88P\"\" \"\"\"Y88.\".$NC\t$H $time$NC - $date$NC
$L ,88P' \`888.$NC\t ${USER} @ ${HOST}$NC
$L ,88P ,ggs. \`88b:$NC
$L d88' ,8P\"' . 888$NC\t GTK Theme »$H $GtkTheme$NC
$L \`88P d8' , 88P$NC\t GTK Icons »$H $GtkIcon$NC
$L \`88: 88. - ,d88'$NC\t GTK Font »$H $GtkFont$NC
$L \`88; Y8b._ _,d8P' $NC\t Term Font »$H $TermFont$NC
$L Y88. \`.\`\"Y8888P\"'$NC \t Wallpaper »$H $Wallpaper$NC
$L \`88b \"-.__$NC
$L \`Y88b$NC \t OS »$H $OS$NC
$L \`Y88.$NC \t WM »$H Awesome$NC $AwVer
$L \`88b.$NC
$L \`Y88b.$NC
$L \`\"Y8b._$NC
$L \`\"\"\"\"$NC
"
}
# --// Crunchbang logo //--
logo-crunch () {
if [ -z "$L" ]; then L='\e[1;37m' ; fi
if [ -z "$H" ]; then H='\e[1;34m' ; fi
echo -e "
$L 888 888 888$NC
$L 888 888 888$NC\t$H $time$NC - $date
$L 888 888 888$NC\t $USER @ $HOST
$L 888 888 888$NC
$L 888888888888888888 888$NC\t GTK Theme »$H $GtkTheme$NC
$L 888888888888888888 888$NC\t GTK Icons »$H $GtkIcon$NC
$L 888 888 888$NC\t GTK Font »$H $GtkFont$NC
$L 888 888 888$NC\t Term Font »$H $TermFont$NC
$L 888888888888888888 888$NC\t Wallpaper »$H $Wallpaper$NC
$L 888888888888888888 888$NC
$L 888 888 $NC\t OS »$H $OS$NC
$L 888 888 888$NC\t WM »$H Awesome $WmVer$NC
$L 888 888 888$NC
$L 888 888 888$NC
"
}
# --/////////////////////--
# --// Take Screenshot //--
# --/////////////////////--
take-shot () {
# quick settings
shotdir="$HOME/images/shots" # without the final slash
shotname="shot_%Y-%m-%d_%H-%M-%S.png"
quality="75" # [0-100]
delay="5" # in seconds
#does the shotdir exist?
if [ ! -d "$shotdir" ]; then mkdir -p "$shotdir"; fi
# take it!
scrot "${shotdir}/$shotname" -q $quality -c -d $delay
}
# --//////////////////--
# --// Help Message //--
# --//////////////////--
script_name="$0"
help-message () {
echo "
USAGE: `basename $script_name` [options] [distro]
Options:
-cn n indicates the number of the color [0-15] of highlights
-Cn n indicates the number of the color [0-15] of logo
-s take a scheenshot (with scrot)
Available Distro (for now):
crunch[bang]
deb[ian]
"
}
# --///////////////////////--
# --// The Main Function //--
# --///////////////////////--
main () {
# Set the default logo (go down for available logo functions)
execute="logo-crunch"
# It will take screenshot? [0=no 1=yes]
confirm_shot="0"
for i in "$@" ; do
case $i in
-h|--help) execute="help-message" ;;
-c*) cat-highlights-color $i ;;
-C*) cat-logo-color $i ;;
-s) confirm_shot="1" ;;
deb*) execute="logo-debian";;
crunch*) execute="logo-crunch";;
*) echo -e "Unknow option ${i}\nUse the option -h for help\n\nExiting..." && exit 1;;
esac
done
$execute
if [ confirm_shot = "1" ] ; then
take-shot
fi
}
# --////////////////////--
# --// EXECUTE SCRIPT //--
# --////////////////////--
main "$@"The program is limited for now.
It read gtk configuration (theme, icon, font) from ~/.gtkrc-2.0 (the path can be changed).
For the wallpaper read the configuration of nitrogen ~/.config/nitrogen/bg-saved.cfg.
Read the .Xdefaults for Urxvt font (maybe I can extend it for terminator but I don't have it, can someone post a example of config?).
the OS from /etc/issue.
For now I don't have a function for identify the wm.
It's use zsh because it's my default shell.
I can extend it with more infos and with more logos but I need the ascii arts.
Enjoy the script. ![]()
Please signal any bugs.
Compliments and criticisms are accepted. ![]()
P.s. sorry for my english, I'm bad at it