YAD Examples

Several complex YAD scripts

List of scripts:
Urxvt configurator
Frontend for find(1)
System information

Configurator for rxvt-unicode

This script read URxvt settings from Xresources database and write new ones to the ~/.Xresources or separate file specified from the command line

Code:

    1 #! /bin/bash
    2 # -*- mode: sh -*-
    3 
    4 
    5 KEY=$RANDOM
    6 
    7 res1=$(mktemp --tmpdir term-tab1.XXXXXXXX)
    8 res2=$(mktemp --tmpdir term-tab2.XXXXXXXX)
    9 res3=$(mktemp --tmpdir term-tab3.XXXXXXXX)
   10 
   11 out=$(mktemp --tmpdir term-out.XXXXXXXX)
   12 
   13 # cleanup
   14 trap "rm -f $res1 $res2 $res3 $out" EXIT
   15 
   16 export YAD_OPTIONS="--bool-fmt=t --separator='\n' --quoted-output"
   17 
   18 rc_file="${1:-$HOME/.Xresources}"
   19 
   20 # parse rc file
   21 while read ln; do
   22     case $ln in
   23         *allow_bold:*) bold=$(echo ${ln#*:}) ;;
   24         *font:*) font=$(echo ${ln#*:}) ;;
   25         *scrollBar:*) sb=$(echo ${ln#*:}) ;;
   26         *loginShell:*) ls=$(echo ${ln#*:}) ;;
   27         *title:*) title=$(echo ${ln#*:}) ;;
   28         *termName:*) term=$(echo ${ln#*:}) ;;
   29         *geometry:*) geom=$(echo ${ln#*:}) ;;
   30         *foreground:*) fg=$(echo ${ln#*:}) ;;
   31         *background:*) bg=$(echo ${ln#*:}) ;;
   32         *highlightColor:*) hl=$(echo ${ln#*:}) ;;
   33         *highlightTextColor:*) hlt=$(echo ${ln#*:}) ;;
   34         *color0:*) cl0=$(echo ${ln#*:}) ;;
   35         *color1:*) cl1=$(echo ${ln#*:}) ;;
   36         *color2:*) cl2=$(echo ${ln#*:}) ;;
   37         *color3:*) cl3=$(echo ${ln#*:}) ;;
   38         *color4:*) cl4=$(echo ${ln#*:}) ;;
   39         *color5:*) cl5=$(echo ${ln#*:}) ;;
   40         *color6:*) cl6=$(echo ${ln#*:}) ;;
   41         *color7:*) cl7=$(echo ${ln#*:}) ;;
   42         *color8:*) cl8=$(echo ${ln#*:}) ;;
   43         *color9:*) cl9=$(echo ${ln#*:}) ;;
   44         *color10:*) cl10=$(echo ${ln#*:}) ;;
   45         *color11:*) cl11=$(echo ${ln#*:}) ;;
   46         *color12:*) cl12=$(echo ${ln#*:}) ;;
   47         *color13:*) cl13=$(echo ${ln#*:}) ;;
   48         *color14:*) cl14=$(echo ${ln#*:}) ;;
   49         *color15:*) cl15=$(echo ${ln#*:}) ;;
   50         !*) ;; # skip comments
   51         "") ;; # skip empty lines
   52         *) misc+=$(echo "$ln\n") ;;
   53     esac
   54 done < <(xrdb -query | grep -i rxvt)
   55 
   56 width=${geom%%x*}
   57 height=${geom##*x}
   58 fn=$(pfd -p -- "$font")
   59 
   60 echo $font
   61 echo $fn
   62 
   63 # main page
   64 yad --plug=$KEY --tabnum=1 --form \
   65     --field=$"Title:" "${title:-Terminal}" \
   66     --field=$"Width::num" ${width:-80} \
   67     --field=$"Height::num" ${height:-25} \
   68     --field=$"Font::fn" "${fn:-Monospace}" \
   69     --field=$"Term:" "${term:-rxvt-256color}" \
   70     --field=$"Enable login shell:chk" ${ls:-false} \
   71     --field=$"Enable scrollbars:chk" ${sb:-false} \
   72     --field=$"Use bold font:chk" ${bold:-false} \
   73     --field=":lbl" "" \
   74     --field=$"Foreground::clr" ${fg:-#ffffff} \
   75     --field=$"Background::clr" ${bg:-#000000} \
   76     --field=$"Highlight::clr" ${hl:-#0000f0} \
   77     --field=$"Highlight text::clr" ${hlt:-#ffffff} > $res1 &
   78 
   79 # palette page
   80 yad --plug=$KEY --tabnum=2 --form --columns=2 \
   81     --field=$"Black::clr" ${cl0:-#2e3436} \
   82     --field=$"Red::clr" ${cl1:-#cc0000} \
   83     --field=$"Green::clr" ${cl2:-#4e9a06} \
   84     --field=$"Brown::clr" ${cl3:-#c4a000} \
   85     --field=$"Blue::clr" ${cl4:-#3465a4} \
   86     --field=$"Magenta::clr" ${cl5:-#75507b} \
   87     --field=$"Cyan::clr" ${cl6:-#06989a} \
   88     --field=$"Light gray::clr" ${cl7:-#d3d7cf} \
   89     --field=$"Gray::clr" ${cl8:-#555753} \
   90     --field=$"Light red::clr" ${cl9:-#ef2929} \
   91     --field=$"Light green::clr" ${cl10:-#8ae234} \
   92     --field=$"Yellow::clr" ${cl11:-#fce94f} \
   93     --field=$"Light blue::clr" ${cl12:-#729fcf} \
   94     --field=$"Light magenta::clr" ${cl13:-#ad7fa8} \
   95     --field=$"Light cyan::clr" ${cl14:-#34e2e2} \
   96     --field=$"White::clr" ${cl15:-#eeeeec} > $res2 &
   97 
   98 # misc page
   99 echo -e $misc | yad --plug=$KEY --tabnum=3 --text-info --editable > $res3 &
  100 
  101 # main dialog
  102 yad --window-icon=utilities-terminal \
  103     --notebook --key=$KEY --tab=$"Main" --tab=$"Palette" --tab=$"Misc" \
  104     --title=$"Terminal settings" --image=utilities-terminal \
  105     --width=400 --image-on-top --text=$"Terminal settings (URxvt)"
  106 
  107 # recreate rc file
  108 if [[ $? -eq 0 ]]; then
  109     mkdir -p ${rc_file%/*}
  110 
  111     eval TAB1=($(< $res1))
  112     eval TAB2=($(< $res2))
  113 
  114     echo -e "! urxvt settings\n" > $out
  115 
  116     # add main
  117     cat <<EOF >> $out
  118 URxvt.title: ${TAB1[0]}
  119 URxvt.geometry: ${TAB1[1]}x${TAB1[2]}
  120 URxvt.font: $(pfd "${TAB1[3]}")
  121 URxvt.termName: ${TAB1[4]}
  122 URxvt.loginShell: ${TAB1[5]}
  123 URxvt.scrollBar: ${TAB1[6]}
  124 URxvt.allow_bold: ${TAB1[7]}
  125 
  126 URxvt.foreground: ${TAB1[9]}
  127 URxvt.background: ${TAB1[10]}
  128 URxvt.highlightColor: ${TAB1[11]}
  129 URxvt.highlightTextColor: ${TAB1[12]}
  130 EOF
  131     # add palette
  132     echo >> $out
  133     for i in {0..15}; do
  134         echo "URxvt.color$i: ${TAB2[$i]}" >> $out
  135     done
  136     echo >> $out
  137 
  138     # add misc
  139     cat $res3 >> $out
  140     echo >> $out
  141 
  142     # load new settings
  143     #xrdb -merge $out
  144     
  145     if [[ $rc_file == $HOME/.Xresources ]]; then
  146         [[ -e $rc_file ]] && sed -i "/^URxvt.*/d" $rc_file
  147         cat $out >> $rc_file
  148     else
  149         mv -f $out $rc_file
  150     fi    
  151 fi

Screenshot:

Frontend for find(1) command

This script uses find(1) and grep(1) commands for finding files by specified conditions including search of content

Code:

    1 #! /bin/sh
    2 # -*- mode: sh -*-
    3 
    4 export find_cmd='@bash -c "run_find %1 %2 %3 %4 %5"'
    5 
    6 export fts=$(mktemp -u --tmpdir find-ts.XXXXXXXX)
    7 export fpipe=$(mktemp -u --tmpdir find.XXXXXXXX)
    8 mkfifo "$fpipe"
    9 
   10 trap "rm -f $fpipe $fts" EXIT
   11 
   12 fkey=$(($RANDOM * $$))
   13 
   14 function run_find
   15 {
   16     echo "6:@disable@"
   17     if [[ $2 != TRUE ]]; then
   18         ARGS="-name '$1'"
   19     else
   20         ARGS="-regex '$1'"
   21     fi
   22     if [[ -n "$4" ]]; then
   23         dt=$(echo "$4" | awk -F. '{printf "%s-%s-%s", $3, $2, $1}')
   24         touch -d "$dt" $fts
   25         ARGS+=" -newer $fts"
   26     fi
   27     if [[ -n "$5" ]]; then
   28         ARGS+=" -exec grep -q -E '$5' {} \;"
   29     fi
   30     ARGS+=" -printf '%p\n%s\n%M\n%TD %TH:%TM\n%u/%g\n'"
   31     echo -e '\f' >> "$fpipe"
   32     eval find "$3" $ARGS >> "$fpipe"
   33     echo "6:$find_cmd"
   34 }
   35 export -f run_find
   36 
   37 exec 3<> $fpipe
   38 
   39 yad --plug="$fkey" --tabnum=1 --form --field=$"Name" '*' --field=$"Use regex:chk" 'no' \
   40     --field=$"Directory:dir" '' --field=$"Newer than:dt" '' \
   41     --field=$"Content" '' --field="yad-search:fbtn" "$find_cmd" &
   42 
   43 yad --plug="$fkey" --tabnum=2 --list --no-markup --dclick-action="xdg-open '%s'" \
   44     --text $"Search results:" --column=$"Name" --column=$"Size:sz" --column=$"Perms" \
   45     --column=$"Date" --column=$"Owner" --search-column=1 --expand-column=1 <&3 &
   46 
   47 yad --paned --key="$fkey" --button="yad-close:1" --width=700 --height=500 \
   48     --title=$"Find files" --window-icon="system-search"
   49 
   50 exec 3>&-

Screenshot:

Gather and show information about system

This script shows information about system, such as hardware info, loaded kernel modules and so on

Code:

    1 #! /bin/sh
    2 # -*- mode: sh -*-
    3 
    4 YAD_OPTIONS="--window-icon='dialog-information' --name=IxSysinfo"
    5 
    6 KEY=$RANDOM
    7 
    8 function show_mod_info {
    9     TXT="\\n<span face='Monospace'>$(modinfo $1 | sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g')</span>"
   10     yad --title=$"Module information" --button="yad-close" --width=500 \
   11         --image="application-x-addon" --text="$TXT"
   12 }
   13 export -f show_mod_info
   14 
   15 # CPU tab
   16 lscpu | sed -r "s/:[ ]*/\n/" |\
   17     yad --plug=$KEY --tabnum=1 --image=cpu --text=$"CPU information" \
   18         --list --no-selection --column=$"Parameter" --column=$"Value" &
   19 
   20 # Memory tab
   21 sed -r "s/:[ ]*/\n/" /proc/meminfo |\
   22     yad --plug=$KEY --tabnum=2 --image=memory --text=$"Memory usage information" \
   23         --list --no-selection --column=$"Parameter" --column=$"Value" &
   24 
   25 # Harddrive tab
   26 df -T | tail -n +2 | awk '{printf "%s\n%s\n%s\n%s\n%s\n%s\n", $1,$7, $2, $3, $4, $6}' |\
   27     yad --plug=$KEY --tabnum=3 --image=drive-harddisk --text=$"Disk space usage" \
   28         --list --no-selection --column=$"Device" --column=$"Mountpoint" --column=$"Type" \
   29         --column=$"Total:sz" --column=$"Free:sz" --column=$"Usage:bar" &
   30 
   31 # PCI tab
   32 lspci -vmm | sed 's/\&/\&amp;/g' | grep -E "^(Slot|Class|Vendor|Device|Rev):" | cut -f2 |\
   33     yad --plug=$KEY --tabnum=4 --text=$"PCI bus devices" \
   34         --list --no-selection --column=$"ID" --column=$"Class" \
   35         --column=$"Vendor" --column=$"Device" --column=$"Rev" &
   36 
   37 # Modules tab
   38 awk '{printf "%s\n%s\n%s\n", $1, $3, $4}' /proc/modules | sed "s/[,-]$//" |\
   39     yad --plug=$KEY --tabnum=5 --text=$"Loaded kernel modules" \
   40         --image="application-x-addon" --image-on-top \
   41         --list --dclick-action='bash -c "show_mod_info %s"' \
   42         --column=$"Name" --column=$"Used" --column=$"Depends" &
   43 
   44 # Battery tab
   45 ( acpi -i ; acpi -a ) | sed -r "s/:[ ]*/\n/" | yad --plug=$KEY --tabnum=6 \
   46     --image=battery --text=$"Battery state" --list --no-selection \
   47     --column=$"Device" --column=$"Details" &
   48 
   49 # Sensors tab
   50 SENSORS=($(sensors | grep -E '^[^:]+$'))
   51 sid=1
   52 cid=1
   53 
   54 for s in ${SENSORS[@]}; do
   55     echo -e "s$sid\n<b>$s</b>\n"
   56     sensors -A "$s" | tail -n +2 | while read ln; do
   57         [[ $ln == "" ]] && continue
   58         echo "$cid:s$sid"
   59         echo $ln | sed -r 's/:[ ]+/\n/'
   60         ((cid++))
   61     done
   62     ((sid++))
   63 done | yad --plug=$KEY --tabnum=7 --text=$"Temperature sensors information" \
   64     --list --tree --tree-expanded --no-selection --column=$"Sensor" --column=$"Value" &
   65 
   66 # main dialog
   67 TXT=$"<b>Hardware system information</b>\\n\\n"
   68 TXT+=$"\\tOS: $(lsb_release -ds) on $(hostname)\\n"
   69 TXT+=$"\\tKernel: $(uname -sr)\\n\\n"
   70 TXT+="\\t<i>$(uptime)</i>"
   71 
   72 yad --notebook --width=600 --height=450 --title=$"System info" --text="$TXT" --button="yad-close" \
   73     --key=$KEY --tab=$"CPU" --tab=$"Memory" --tab=$"Disks" --tab=$"PCI" --tab=$"Modules" \
   74     --tab=$"Battery" --tab=$"Sensors" --active-tab=${1:-1}

Screenshot:

YAD Examples: 6 комментариев

  1. How to create package:

    Add run.sh and uninstall.sh scripts to GAME DIR and edit run.sh only.

    find ./”GAME DIR” -type f -print0 | xargs -0 chmod 0600 && find ./”GAME DIR” -type d -print0 | xargs -0 chmod 0700

    chmod 0700 “GAME EXE FILES”

    tar -cf – “GAME DIR” | ./zstd –ultra -22 -T -v -o arc

    ———————————————————————————————
    Edit ysi script (9 lines):

    # General application description
    app=”GAME NAME” # 1
    export app
    icon=”path/to/icon/without/gamenamedir/icon.png” # 2
    export icon
    ver=”0.0.0″ # 3
    export ver
    appurl=https://gamesite.domain # 4
    export appurl

    # File sizes (bytes)
    appsz=000000000 # 5
    export appsz
    arcsz=0000000 # 6
    export arcsz
    picsz=00000 # 7
    export picsz
    ysisz=00000 # 8
    export ysisz

    # Skipped file size (ysisz + 1 byte)
    ysisk=00000 # 9
    export ysisk

    ———————————————————————————————
    cat ysi yad pic pv zstd arc > “GAME NAME (version).sh” && chmod 0500 *.sh

  2. YAD Simple Installer

    GUI:
    – установка по выбранному пути
    – создание файла запуска в меню приложений (по выбору)
    – создание файла запуска на рабочем столе (по выбору)
    – проверка свободного места для установки
    – проверка прав на установку по выбранному пути
    – запрос на перезапись уже существуещего каталога по выбранному пути
    – запрос на отмену установки в её процессе
    – удаление каталога по выбранному пути при отмене установки
    – запрет установки через команду sudo или от пользователя root
    – поддержка Wayland
    – веб-ссылка на сайт разработчика/издателя (возможна любая)

    Терминал:
    – отображение справки (опция “-h”)
    – отображение информации о дистрибутиве (опция “-i”)
    – отображение размера архива в дистрибутиве (опция “-s”)
    – установка из терминала в текущий каталог (опция “-e”)
    – распаковка всех файлов дистрибутива (опция “-a”)

    Локализация графического интерфейса. Можно добавить нужную в скрипт.
    Русская и английская уже присутствуют. Наследуется от локали окружения.

    Удаление всех временных файлов установщика после завершения его работы.

  3. #!/usr/bin/env bash
    #
    # YAD Simple Installer script version 25.04.2020
    # by Хрюнделёк & Kron4ek
    # The script can support any compression utility
    # https://yadi.sk/i/6XsWyS6O-4YKRA
    # Thanks to Misko-2083 for YAD idea
    # https://github.com/Misko-2083
    #
    # YAD (Yet Another Dialog) version 6.0
    # by Victor Ananjevsky
    # https://github.com/v1cont/yad
    #
    # zstd (Zstandard — Data compression algorithm) version 1.4.4
    # by Yann Collet at Facebook
    # https://github.com/facebook/zstd
    #
    # GNU coreutils
    # https://gnu.org/software/coreutils
    #
    ################## Unique values for each application ##################

    # General application description
    app=”Black Mesa”
    export app
    icon=”icon.png”
    export icon
    ver=”1.1″
    export ver
    appurl=https://www.crowbarcollective.com
    export appurl

    # File sizes
    appsz=28496496640
    export appsz
    arcsz=175833088
    export arcsz
    picsz=25298
    export picsz
    ysisz=12511
    export ysisz

    # Skipped file size
    ysisk=12512
    export ysisk

    ####################### Immutable script content #######################

    # Installer
    ysi=”YAD Simple Installer”
    export ysi
    ysiver=”25.04.20, rutracker.org”
    export ysiver

    # Prevent sudo/root from starting YSI
    if [ “$EUID” = 0 ]; then
    if (locale | grep -e ‘ru_RU’ >/dev/null); then
    echo -e “\033[5;1;31m”
    echo ” Не устанавливайте неизвестное ПО через команду sudo \
    или от пользователя root”
    echo -e “\033[0m”
    exit 0
    else
    echo -e “\033[5;1;31m”
    echo ” Do not use the sudo command or the root user to \
    install unknown software”
    echo -e “\033[0m”
    exit 0
    fi
    fi

    # Initial set
    dir=”$(dirname “$(realpath “$0″)”)”
    export dir
    package=”$dir/$(basename “$0″)”
    export package
    rnum=$RANDOM
    export rnum
    ysitmp=”$(mktemp -d –tmpdir ysi.$rnum.XXX)”
    export ysitmp
    mkdir -p “$ysitmp”

    # Fixed file sizes
    pvsz=61376
    export pvsz
    yadsz=244976
    export yadsz
    zstdsz=797528
    export zstdsz

    # Skipped file sizes
    yadsk=”$((ysisk+yadsz))”
    export yadsk
    picsk=”$((yadsk+picsz))”
    export picsk
    pvsk=”$((picsk+pvsz))”
    export pvsk
    zstdsk=”$((pvsk+zstdsz))”
    export zstdsk

    # Cleaning up temporary YSI stuff after exiting
    ysi_cleanup () {
    if [ ! -v tempintrap ]; then
    tempintrap=1
    pkill -f “yad –paned –key=$rnum”
    pkill -f “yad –plug=$rnum”
    rm -rf “$main_proc_id” “$progress_pipe” “$percentage_pipe” \
    “$form_pipe” “$ysitmp” “$HOME/.config/yad.conf”
    fi
    }
    trap ysi_cleanup 0 1 2 3 15

    # Display help in the terminal
    ysi_help () {
    echo
    echo -e “\033[1;32m $ysi\033[0m (version $ysiver)”
    echo
    echo -e “\033[1;37m Available options:\033[0m”
    echo
    echo -e ” -h\tDisplay this help message”
    echo -e ” -i\tDisplay package info”
    echo -e ” -s\tDisplay embedded archive size”
    echo -e ” -e\tExtract files from embedded archive directly”
    echo -e ” -a\tExtract all embedded files from the package”
    echo
    echo -n ” More info: “; \
    echo -e “\033[34mhttps://yadi.sk/i/6XsWyS6O-4YKRA\033[0m”
    echo
    }
    if [ $# = 0 ]; then
    echo
    echo -n ” $ysi (version $ysiver):”; \
    echo -e “\033[1;32m $app\033[0m (version $ver)”
    echo
    else
    case “$1” in
    -h)
    ysi_help
    exit 0
    ;;

    # Display package info
    -i)
    echo
    echo -e “\033[1;32m $app\033[0m (version $ver)”
    echo
    exit 0
    ;;

    # Display application embedded archive size
    -s)
    echo
    echo -e “\033[1;32m Embedded archive size at the end of the \
    package:\033[0m $arcsz bytes”
    echo
    exit 0
    ;;

    # Extract files from embedded archive directly
    -e)
    echo
    echo -n ” $ysi (version $ysiver):”; \
    echo -e “\033[1;32m $app\033[0m (version $ver)”
    echo -e “\033[1;33m”
    echo ” Extracting files from embedded archive:”
    echo -e “\033[0m”
    if tail -c +”$pvsk” “$package” | head -c “$zstdsz” > \
    “$ysitmp”/ysizstd
    chmod 0700 “$ysitmp”/ysizstd
    zstd=”$ysitmp”/ysizstd
    sleep 3
    tail -c “$arcsz” “$package” | tar -I “$zstd” -C “$dir” -xvf – \
    2>/dev/null; then
    echo -e “\033[1;32m”
    echo ” Done”
    echo -e “\033[0m”
    else
    echo -e “\033[1;31m”
    echo ” Canceled”
    echo -e “\033[0m”
    fi
    exit 0
    ;;

    # Extract all embedded files from the package
    -a)
    echo
    echo -n ” $ysi (version $ysiver):”; \
    echo -e “\033[1;32m $app\033[0m (version $ver)”
    echo -e “\033[1;34m”
    echo -e ” Extracting all embedded files to\033[0m $dir/$app \
    ($ver) – extracted”
    echo
    if mkdir -p “$dir/$app ($ver) – extracted”
    echo -e “\033[1;33m Wait…\033[0m”
    head -c “$ysisz” “$package” > \
    “$dir/$app ($ver) – extracted/ysi.sh”
    tail -c +”$ysisk” “$package” | head -c “$yadsz” > \
    “$dir/$app ($ver) – extracted/yad”
    tail -c +”$yadsk” “$package” | head -c “$picsz” > \
    “$dir/$app ($ver) – extracted/pic.jpg”
    tail -c +”$picsk” “$package” | head -c “$pvsz” > \
    “$dir/$app ($ver) – extracted/pv”
    tail -c +”$pvsk” “$package” | head -c “$zstdsz” > \
    “$dir/$app ($ver) – extracted/zstd”
    tail -c “$arcsz” “$package” > \
    “$dir/$app ($ver) – extracted/arc.tar.zst”; then
    echo -e “\033[1;32m”
    echo ” Done”
    echo -e “\033[0m”
    else
    echo -e “\033[1;31m”
    echo ” Canceled”
    echo -e “\033[0m”
    fi
    exit 0
    ;;
    *)
    ysi_help
    exit 0
    ;;
    esac
    fi

    # Extract required files to /tmp
    tail -c +”$ysisk” “$package” | head -c “$yadsz” >”$ysitmp”/yad
    tail -c +”$yadsk” “$package” | head -c “$picsz” >”$ysitmp”/pic
    tail -c +”$picsk” “$package” | head -c “$pvsz” >”$ysitmp”/pv
    tail -c +”$pvsk” “$package” | head -c “$zstdsz” >”$ysitmp”/zstd
    chmod 0700 “$ysitmp”/*
    yad=”$ysitmp”/yad
    export yad
    pic=”$ysitmp”/pic
    export pic
    pv=”$ysitmp”/pv
    export pv
    zstd=”$ysitmp”/zstd
    export zstd

    # Process IDs
    main_proc_id=”$(mktemp -u –tmpdir ysi-started.$rnum.XXX)”
    export main_proc_id
    progress_pipe=”$(mktemp -u –tmpdir ysi-progress_pipe.$rnum.XXX)”
    export progress_pipe
    mkfifo “$progress_pipe”
    percentage_pipe=”$(mktemp -u –tmpdir ysi-percentage_pipe.$rnum.XXX)”
    export percentage_pipe
    mkfifo “$percentage_pipe”
    form_pipe=”$(mktemp -u –tmpdir ysi-form_pipe.$rnum.XXX)”
    export form_pipe
    mkfifo “$form_pipe”

    # Localization
    if (locale | grep -e ‘ru_RU’ >/dev/null); then
    msgspace=”Нет места для установки по выбранному пути.”
    msgpermission=”Нет прав на установку по выбранному пути.”
    msgcomplete=”Установка завершена.”
    msgcancel=”Установка отменена.”
    instpath=” Путь установки:”
    menulnch=” Создать значок запуска в меню приложений”
    desklnch=” Создать значок запуска на рабочем столе”
    beginst=” Начать установку”
    title=”Установка”
    dlgrepl=”уже есть по выбранному пути.
    Заменить файлы?”
    dlgquit=”Если выйти до завершения установки, то все файлы $app будут удалены по выбранному пути.
    Выйти?”
    y=”Да”
    n=”Нет”
    else
    msgspace=”No free space to install on the selected path.”
    msgpermission=”No permission to install on the selected path.”
    msgcomplete=”Installation completed.”
    msgcancel=”Installation canceled.”
    instpath=” Installation path:”
    menulnch=” Create a launcher in the applications menu”
    desklnch=” Create a launcher on the desktop”
    beginst=” Begin Installation”
    title=”Installation”
    dlgrepl=”already exists on the selected path.
    Do you want to replace files?”
    dlgquit=”If you quit the incomplete installation, all $app files will be deleted on the selected path.
    Do you want to quit?”
    y=”Yes”
    n=”No”
    fi

    export msgspace
    export msgpermission
    export msgcomplete
    export msgcancel
    export title
    export dlgrepl
    export y
    export n

    # Xwayland session
    if ps -C “Xwayland” >/dev/null; then
    export GDK_BACKEND=x11
    fi

    # User environment launchers
    if [ -z “$XDG_CONFIG_HOME” ]; then
    XDG_CONFIG_HOME=”$HOME/.config”
    fi
    # shellcheck source=/dev/null
    source “$XDG_CONFIG_HOME/user-dirs.dirs” 2>/dev/null

    if [ -z “$XDG_DATA_HOME” ]; then
    XDG_DATA_HOME=”$HOME/.local/share”
    fi

    if [ -z “$XDG_DESKTOP_DIR” ]; then
    XDG_DESKTOP_DIR=”$HOME/Desktop”
    fi

    desklauncher=”$XDG_DESKTOP_DIR/$app.desktop”
    export desklauncher
    menudir=”$XDG_DATA_HOME/applications”
    export menudir
    menulauncher=”$menudir/$app.desktop”
    export menulauncher

    # Main function
    ysi_install () {

    # Installation is running
    echo “@disabled@” > “$form_pipe” # disable path selection
    echo “@disabled@” > “$form_pipe” # disable 1st checkbox
    echo “@disabled@” > “$form_pipe” # disable 2nd checkbox
    echo “@disabled@” > “$form_pipe” # disable installation button
    echo “$appurl” > “$form_pipe” # website link
    true > “$main_proc_id”

    # Check selected directory write access
    if [ ! -w “$1” ]; then
    echo “#$msgpermission” >> “$progress_pipe”
    exit 0
    fi

    # Check available space
    freespace=”$(($(stat -f –format=”%a*%s” “$1″ 2>/dev/null)))”
    if [ “$freespace” -le “$appsz” ]; then
    echo “#$msgspace” >> “$progress_pipe”
    exit 0
    fi

    # Check if the application directory already exists
    if [ -d “$1/$app” ]; then
    “$yad” –title=”$app – $title” –width=450 –text=”$app $dlgrepl” \
    –on-top –center –image=gtk-dialog-question \
    –window-icon=”system-software-install” \
    –button=”$n!gtk-no:1″ –button=”$y!gtk-yes:0″
    if [[ $? = 1 || $? = 252 ]]; then
    echo “#$msgcancel” >> “$progress_pipe”
    exit 0
    fi
    fi

    while read -r line; do

    # If the line is an integer number
    if [[ “$line” == +([0-9]) ]]; then
    echo “$line” >> “$progress_pipe”
    fi
    done \
    “$percentage_pipe” | tar -C “$1” -I “$zstd” -xf – & echo $! \
    > “$main_proc_id”

    # Wait from here and it returns exit status
    wait “$(<"$main_proc_id")"
    # shellcheck disable=SC2181
    if [ $? = 0 ]; then

    # Create launchers in the applications menu
    # and/or on the desktop
    if [ "$2" = "TRUE" ]; then
    [ ! -d "$menudir" ] && mkdir -p "$menudir"
    cat < “$menulauncher”
    [Desktop Entry]
    Name=$app
    Exec=”$1/$app/run.sh”
    Icon=$1/$app/$icon
    Type=Application
    Categories=Game;
    StartupNotify=true
    Comment=Start $app
    Comment[ru_RU]=Запустить $app
    EOF
    chmod 0700 “$menulauncher”
    fi

    if [ “$3” = “TRUE” ]; then
    cat < “$desklauncher”
    [Desktop Entry]
    Name=$app
    Exec=”$1/$app/run.sh”
    Icon=$1/$app/$icon
    Type=Application
    Categories=Game;
    StartupNotify=true
    Comment=Start $app
    Comment[ru_RU]=Запустить $app
    EOF
    chmod 0700 “$desklauncher”
    fi
    true > “$main_proc_id”
    echo “#$msgcomplete” >> “$progress_pipe”
    else
    true > “$main_proc_id”
    # shellcheck disable=SC2115
    setsid rm -r “$1/$app”
    echo “#$msgcancel” >> “$progress_pipe”
    fi

    # Forms fields final values
    echo “@disabled@” > “$form_pipe” # disable path selection
    echo “@disabled@” > “$form_pipe” # disable 1st checkbox
    echo “@disabled@” > “$form_pipe” # disable 2nd checkbox
    echo “@disabled@” > “$form_pipe” # disable installation button
    echo “$appurl” > “$form_pipe” # website link
    }
    export -f ysi_install
    install=’bash -c “ysi_install %1 %2 %3″‘
    export “install”
    exec 3 “$progress_pipe”
    exec 4 “$form_pipe”

    # YSI window
    while true; do
    if [ -s “$main_proc_id” ]; then
    # Installation is running
    echo “@disabled@” > “$form_pipe” # disable path selection
    echo “@disabled@” > “$form_pipe” # disable 1st checkbox
    echo “@disabled@” > “$form_pipe” # disable 2nd checkbox
    echo “@disabled@” > “$form_pipe” # disable installation button
    echo “$appurl” > “$form_pipe” # website link
    else
    # Initial values
    echo “$HOME/ ” > “$form_pipe” # default path
    echo “FALSE” > “$form_pipe” # default 1st checkbox value
    echo “FALSE” > “$form_pipe” # default 2nd checkbox value
    echo “$install” > “$form_pipe” # installation button
    echo “$appurl” > “$form_pipe” # website link
    fi

    setsid “$yad” –plug=$rnum –tabnum=1 –form \
    –image=”$pic” –image-on-top \
    –field=” $instpath:DIR” \
    –field=” $menulnch:CHK” \
    –field=” $desklnch:CHK” \
    –field=” $beginst!system-software-install:FBTN” \
    –field=”$appurl:LINK” \
    –cycle-read <&4 &

    "$yad" –plug=$rnum –tabnum=2 –progress <&3 &

    "$yad" –paned –key=$rnum –no-buttons \
    –title="$app ($ver) – $title" –window-icon="system-software-install" \
    –fixed –center –no-escape

    # Closing YSI window during the installation process
    if [[ -s $main_proc_id && $? = 252 ]]; then
    if "$yad" –title="$app – $title" –width=450 \
    –text="$dlgquit" –on-top –center –image=gtk-dialog-question \
    –window-icon="system-software-install" \
    –button="$n!gtk-no:1" –button="$y!gtk-yes:0"; then
    bckpid="$( “$main_proc_id”
    kill “$bckpid” 2>/dev/null
    fi
    else
    break
    fi

    done

    exec 3>&-
    exec 4>&-
    exit 0

    https://i111.fastpic.ru/big/2020/0427/9c/32495bcf1997f2f42c930ac77a48669c.png

  4. #!/bin/bash
    # ======================>2019> nikonik@chita.ru << :
    # ===================================================
    # : ____ _ _ :
    # : / ___|| |_ ___ _ __| | __ :
    # : \___ \| __/ _ \| '__| |/ / :
    # : ___) | || (_) | | | Setting_Styles < XXX .
    # Copyright © Nikolay Andriychuk.
    # Inherits: acknowledgement.
    # yad – display GTK+ dialogs in shell scripts .
    # XXX > YAD is the fork of Zenity program logfile
    #BASH_XTRACEFD=19

    #set -x

    # Проверить зависимости:
    [[ “$XDG_CURRENT_DESKTOP” == “XFCE” ]] || exit 1
    echo “$XDG_CURRENT_DESKTOP”
    command -v yad gifsicle scrot wmctrl >/dev/null 2>&1 || { echo >&2 “I require yad gifsicle scrot wmctrl but it not installed. Aborting.”; exit 1; }

    llkey=$(($RANDOM * $$))

    cd `dirname $0`; echo “$PWD”

    if [ ! -f “/tmp/Stork-index.theme” ]; then
    echo -e “1200×640+266+73” > /tmp/stork_geometry
    ./Setting-style/setting-create/setting-create.sh
    wait
    fi

    function sayonara {
    XWININFO=$(xwininfo -id $YAD_XID)
    ARRAY=(${XWININFO#* X: })
    AX=${ARRAY[0]}
    AY=${ARRAY[4]}
    RX=${ARRAY[8]}
    RY=${ARRAY[12]}
    W=${ARRAY[14]}
    H=${ARRAY[16]}
    X=$((AX-RX))
    Y=$((AY-RY))
    echo “$W”x”$H”+”$X”+”$Y” > /tmp/stork_geometry
    kill -s SIGUSR1 $YAD_PID
    }; export -f sayonara

    help_stork () { yad –on-toop –borders=20 \
    –window-icon=”help-browser” –title=”Help” –text=”
    \ Stork Dizayn _ Styles of design.

    Stork Dizayn это набор программ,
    которые обеспечивают полнофункциональную рабочую среду Xfce.

    Следующие программы вместе с интегриванными являются частью ядра Stork Dizayn:

    Поддержка настроек Менеджер рабочего стола (xfdesktop)
    Устанавливает цвет фона или изображение с дополнительным меню приложения или значки для свёрнутых приложений, ярлыков, устройств и каталогов.

    Поддержка настроек Панель (xfce4-panel)
    Ярлыки, кнопки окон, меню приложений, переключатель рабочих столов и другое.

    Поддержка настроек Менеджер сеансов (xfce4-session)
    Восстанавливает ваш предыдущий сеанс работы и позволяет выключать компьютер из Xfce Compton Compiz Metacitu Emerald…

    Поддержка настроек (xfce4-settings)
    Конфигурация системы для контроля различных аспектов рабочего стола, например, внешнего вида, дисплея, клавиатуры и настроек мыши.

    Stork Dizayn также является программой, содержащей несколько библиотек, которые хорошо интегрируются в окружение рабочего стола
    и помогают создавать приложения автонастройки.

    Компоненты Stork Dizayn распространяются под условиями свободных лицензий или лицензий открытого кода:
    GPL и BSDL для приложений и LGPL и BSDL для библиотек.
    Подробности можно найти в документации, в исходном коде и на веб-сайте Stork Dizayn (http://www.Stork Dizayn. none).

    Благодарим вас за проявленный интерес к Stork Dizayn.

    – От разработчика Stork Dizayn: nikonik@chita.ru

    }; export -f help_stork

    Panel_num=$(grep –only-matching –max-count=1 ‘panel-[0-1]’ ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml | head -n1) 2> /dev/null

    set_panel_p(){

    xfconf-query –channel xfce4-panel –property “$@”
    }

    WMANAGER=$(wmctrl -m | grep Name: | awk ‘{print $2}’)
    GTKTHEME=”$(xfconf-query -c xsettings -p /Net/ThemeName 2> /dev/null)”
    GTK3THEME=”$(cat ~/.Setting-t-ini.txt | head -n1 2> /dev/null)”
    [[ -z ${GTK3THEME} ]] && GTK3THEME=”${GTKTHEME}”

    NUMET=”5″
    if pidof gtk-window-decorator; then
    BTHEMEXME=”$(gsettings get org.gnome.metacity.theme name | tr -d \’\” )”
    THEMEXM=”metacity-1″
    TXTMXEM=”themes”
    elif [[ “$WMANAGER” == ‘Metacity’ ]]; then
    BTHEMEXME=”$(gsettings get org.gnome.metacity.theme name | tr -d \’\” )”
    THEMEXM=”metacity-1″
    TXTMXEM=”themes”
    elif `ps -ef | grep ‘[e]merald’`; then
    BTHEMEXME=$(cat ~/.emerald/theme/themename | gawk -F’ ‘ ‘{print $NF}’ | tr -d \’\” )
    WMANAGER=”Emerald”
    TXTMXEM=”emerald/themes”
    NUMET=”6″
    elif [[ “$WMANAGER” == ‘Xfwm4’ ]]; then
    BTHEMEXME=”$(xfconf-query -c xfwm4 -p /general/theme -v | tr -d \’\” )”
    THEMEXM=”xfwm4″
    TXTMXEM=”themes”
    WMANAGER=”Themes_Xfwm4″
    else
    error_exit
    fi

    themelist=”Default”
    for dk in $(cat ./NetgtkTheme|grep -se “gtk-2.0″|cut -d/ -f1-5); do
    theme=${dk##*/}
    if [[ -d “${dk}/gtk-2.0″ ]]; then
    [[ $themelist ]] && themelist=”$themelist!”
    [[ $theme == $GTKTHEME ]] && theme=”^$theme”
    themelist+=”$theme”
    fi
    done

    theme3list=
    for dgk in $(cat ./NetgtkTheme|grep -se “gtk-3.0″|cut -d/ -f1-5); do
    theme=${dgk##*/}
    if [[ -d “${dgk}/gtk-3.0″ ]]; then
    [[ $theme3list ]] && theme3list=”$theme3list!”
    [[ $theme == $GTK3THEME ]] && theme=”^$theme”
    theme3list+=”$theme”
    fi
    done

    WhemeBorders=
    for dbk in $(cat ./GeneralTheme|grep -se “${THEMEXM}”|cut -d/ -f1-${NUMET}); do
    theme=${dbk##*/}
    if [[ -d “${dbk}/${THEMEXM}” ]]; then
    [[ $WhemeBorders ]] && WhemeBorders=”$WhemeBorders!”
    [[ $theme == $BTHEMEXME ]] && theme=”^$theme”
    WhemeBorders+=”$theme”
    fi
    done

    set_gtktri_t(){
    GTK3THEME=$1
    [[ -z $GTK3THEME ]] && GTK3THEME=$(xfconf-query -c xsettings -p /Net/ThemeName -v)
    GTK3DIR=$(LANG=C; find /usr/share/themes/${GTK3THEME}/ ~/.themes/${GTK3THEME}/ ~/.local/share/themes/${GTK3THEME}/ -type d -name ‘gtk-3.0’ 2>&1 | grep -v ‘No such file or directory’ | head -n 1)

    if ! [[ -d ${GTK3DIR} ]]; then
    echo “No such file or directory themes gtk-3.0 :EXIT”
    rm -R ~/.config/gtk-3.0
    exit 1
    else
    mkdir –parents ~/.themes/Default/gtk-3.0
    rm -R ~/.themes/Default/gtk-3.0
    cp -R “$GTK3DIR” ~/.themes/Default/gtk-3.0
    rm -R ~/.config/gtk-3.0
    ln -s “$GTK3DIR” ~/.config/gtk-3.0
    echo “$GTK3THEME” > /tmp/Setting-t-ini.txt
    echo “$GTK3THEME” > ~/.Setting-t-ini.txt
    fi
    }

    # Узнать свойство панели.
    Panel_opacity=$(set_panel_p /panels/”${Panel_num}”/leave-opacity -v)
    Panel_alpha=$(set_panel_p /panels/”${Panel_num}”/background-alpha -v)
    Panel_style=$(set_panel_p /panels/”${Panel_num}”/background-style -v)
    PanelTheme=$(set_panel_p /panels/”${Panel_num}”/background-image -v)
    PanelSize=$(set_panel_p /panels/${Panel_num}/size -v)
    PanelPosition=$(set_panel_p /panels/”${Panel_num}”/position -v)
    workspace_count=$(xfconf-query -c xfwm4 -p /general/workspace_count -v)
    IconTheme=”$(xfconf-query -c xsettings -p /Net/IconThemeName -v)”
    CursorTheme=”$(xfconf-query -c xsettings -p /Gtk/CursorThemeName -v)”

    TitleFont=”$(xfconf-query -c xfwm4 -p /general/title_font -v)”

    Title_A=”$(xfconf-query -c xfwm4 -p /general/title_alignment -v)”
    Title_alignment=’Left!^Centr!Right’
    [[ ${Title_A} == left ]] && Title_alignment=’^Left!Centr!Right’
    [[ ${Title_A} == right ]] && Title_alignment=’Left!Centr!^Right’

    BUTONLT=”$(xfconf-query -c xsettings -p /Gtk/DecorationLayout | awk -F ‘,’ ‘{print $1}’)”
    if [[ ${BUTONLT} == close ]]; then
    B_LAYOUT=’OSX_Layout!Normal_Layout’
    else
    B_LAYOUT=’Normal_Layout!OSX_Layout’
    fi

    STYLE=”0 \(use system style\)!1 Solid color!^2 Bacground Image”
    POZITION=”Верх: p=6;x=960;y=16!Низ: p=8;x=960;y=1063!Лев: p=6;x=14;y=540!Прав: p=2;x=1906;y=540″
    COMPOZITING=$(xfconf-query -c xfwm4 -p /general/use_compositing -v)
    MINIATYRE_VIEW=”FALSE”

    ### 01Transparency /general/title_alignment Position
    yad –plug=”$llkey” –tabnum=1 –borders=20 –image-on-top –no-click –image=”./Data-icons/scalable/stork-logo.png” –inc-buttons –vertical –align=left \
    –form –field=”Desktop_Settings!./Data-icons/16/wm-xubynu.png! Диспетчер настроек: Приложения для настройки рабочего стола:BTN” ‘xfce4-settings-manager &’ \
    –form –field=”Themes_Gtk2::”CBE “${themelist}” \
    –form –field=”Themes_Gtk3::”CBE “${theme3list}” \
    –form –field=”$WMANAGER::”CBE “${WhemeBorders}” \
    –form –field=”Use_Compositing::”CHK “${COMPOZITING}” \
    –form –field=”Button_Layout::”CB “${B_LAYOUT}” \
    –form –field=”Title_alignment::”CB “${Title_alignment}” \
    –form –field=”Panel_opacity::”SCL “${Panel_opacity}!10..100!1!0” \
    –form –field=”Panel_Size::”NUM “${PanelSize}!24..72!1!0” \
    –form –field=”Workspace_count::”NUM “${workspace_count}!1..8!1!0” \
    –form –field=”Panel_style::”CB “${STYLE}” \
    –form –field=”Panel_Position::”CB “${POZITION}” \
    –form –field=”Panel_Miniature_view::”CHK “${MINIATYRE_VIEW}” \
    –form –field=”Title_Font::FN” “${TitleFont}” \
    \
    “” “” “” “” “” “” “” “” “” “” “” “” “” “” | while read line; do
    DATANAME1=` echo $line | awk -F’|’ ‘{print $1}’`
    xfconf-query -s `echo $line | awk -F’|’ ‘{print $2}’` -c xsettings -p /Net/ThemeName
    DATANAME3=` echo $line | awk -F’|’ ‘{print $3}’` && set_gtktri_t “${DATANAME3}”
    [[ “$WMANAGER” == ‘Themes_Xfwm4′ ]] && xfconf-query -s `echo $line | awk -F’|’ ‘{print $4}’` -c xfwm4 -p /general/theme
    [[ “$THEMEXM” == ‘metacity-1′ ]] && gsettings set org.gnome.metacity.theme name `echo $line | awk -F’|’ ‘{print $4}’`
    if [[ “$WMANAGER” == “Emerald” ]]; then
    find “${HOME}/.emerald/theme/” -delete
    cp -a “${HOME}/.emerald/themes/$(echo $line | awk -F’|’ ‘{print $4}’)/”. “${HOME}/.emerald/theme” || cp -a “/usr/share/emerald/themes/$(echo $line | awk -F’|’ ‘{print $4}’)/”. “${HOME}/.emerald/theme”
    emerald –replace &
    fi
    DATANAME5=` echo $line | awk -F’|’ ‘{print $5}’` && xfconf-query -c xfwm4 -p /general/use_compositing -s $(echo “${DATANAME5,,}” | tr _ -)
    DATANAME6=` echo $line | awk -F’|’ ‘{print $6}’`
    [[ $DATANAME6 == Normal_Layout ]] && xfconf-query -c xfwm4 -p /general/button_layout -s “OS|HMC” || xfconf-query -c xfwm4 -p /general/button_layout -s “CHM|SO”
    DATANAME7=` echo $line | awk -F’|’ ‘{print $7}’` && xfconf-query -c xfwm4 -p /general/title_alignment -s $(echo “${DATANAME7,,}” | tr _ -)
    xfconf-query -c xfce4-panel -p /panels/${Panel_num}/leave-opacity -s ` echo $line | awk -F’|’ ‘{print $8}’`
    xfconf-query -c xfce4-panel -p /panels/${Panel_num}/size -s ` echo $line | awk -F’|’ ‘{print $9}’`
    DATANAME10=`echo $line | awk -F’|’ ‘{print $10}’` && xfconf-query -c xfwm4 -p /general/workspace_count -s “${DATANAME10}”
    xfconf-query -c xfce4-panel -p /panels/${Panel_num}/background-style -s `echo $line | awk -F’|’ ‘{print $11}’ | awk -F’ ‘ ‘{print $1}’`
    xfconf-query -c xfce4-panel -p /panels/${Panel_num}/position -s `echo $line | awk -F’|’ ‘{print $12}’ | awk -F’: ‘ ‘{print $2}’`
    DATANAME13=`echo $line | awk -F’|’ ‘{print $13}’`
    xfconf-query -c xfwm4 -p /general/title_font -s “$(echo $line | awk -F’|’ ‘{print $14}’)”

    echo “$DATANAME1, $DATANAME2, $DATANAME3, $DATANAME4, $DATANAME5, $DATANAME6, $DATANAME7, $DATANAME8, $DATANAME9, $DATANAME10, $DATANAME11, $DATANAME12, $DATANAME13, $DATANAME14, ” > ./777a777
    done \
    &
    ###

    ### 02
    yad –icons –plug=”${llkey}” –tabnum=”2″ –item-width=”128″ \
    –text=” Select the icon. Click the mouse.” –tooltip –monitor –output-by-row \
    –read-dir=”$HOME/.storkdata/Aplication/” –single-click &

    ### 03
    yad –center –window-icon=”./Data-icons/scalable/stork.png” –borders=10 –paned –orient=”horizontal” –width=”1200″ –height=”640″ –key=”$llkey” \
    –title=”Setting_Styles” –sticky –auto-kill –text-align=”left” –focus-field=”2″ \
    –no-escape –response=0 –buttons-layout=edge \
    –button=”gtk-apply!view-refresh! Применить настройки?”:”bash -c sayonara” –geometry “$(cat /tmp/stork_geometry 2>/dev/null)” \
    –button=”gtk-refresh!view-refresh! Обновить рабочий стол?”:’./Setting-style/setting-theme/revise-gtk_avto &’ \
    –button=”W-manager!view-refresh! Заменить Менеджер Окон… “:’./Setting-style/setting-compositting/wm-manager &’ \
    –button=”gtk-about!gtk-about! О программе, Stork?”:”bash -c help_stork” \
    –button=”gtk-quit!gtk-quit! Выйти из программы?”:1

    ret=$?
    [[ $ret == 1 ]] || [[ $ret == 252 ]] && exit
    echo $ret

    [[ $ret == 0 ]] && sleep 1 && ./SettingStyles.sh &

    exit

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *