From 4116077b59df7e790aeb9ebf08376fb0f64f3716 Mon Sep 17 00:00:00 2001 From: Johannes Kamprad Date: Fri, 4 Aug 2023 20:47:02 +0200 Subject: [PATCH] Delete eos-script-lib-yad --- eos-script-lib-yad | 825 --------------------------------------------- 1 file changed, 825 deletions(-) delete mode 100644 eos-script-lib-yad diff --git a/eos-script-lib-yad b/eos-script-lib-yad deleted file mode 100644 index 53fc6c1..0000000 --- a/eos-script-lib-yad +++ /dev/null @@ -1,825 +0,0 @@ -#!/bin/bash -# -# EndeavourOS bash scripts "library". Functions using 'yad'. -# -# - ALL FUNCTIONS HERE START WITH "eos_yad_" AND ARE EXPORTED. -# - NO GLOBAL VARIABLES ARE USED NOR PROVIDED. -# -# User MUST declare the following exports in the *using* bash code: -# -# export -f eos_yad -# export -f eos_yad_terminal -# export -f eos_yad_check_internet_connection -# export -f eos_yad_GetArgVal -# export -f eos_yad_RunCmdTermBash -# export -f eos_yad_problem -# export -f eos_yad_DIE -# export -f eos_yad_WARN -# -# export -f eos_yad__detectDE -# export -f eos_yad_GetDesktopName -# export -f eos_GetArch -# export -f eos_select_browser -# export -f eos_yad_nothing_todo -# -# The two last functions above do not use yad. -# -# shellcheck disable=SC1090 # Don't show warnings on sourceing via a variable - -source /etc/eos-script-lib-yad.conf # for EOS_ROOTER and other configs - -export EOS_WICON=/usr/share/endeavouros/EndeavourOS-icon.png -export EOS_YAD_STARTER_CMD="/usr/bin/yad --window-icon=$EOS_WICON" - -eos_yad() { - GDK_BACKEND=x11 $EOS_YAD_STARTER_CMD "$@" -} - -translations_dir=/usr/share/endeavouros/scripts # needed in translations.bash -source $translations_dir/translations.bash || { - echo "$translations_dir/translations.bash not found!" >&2 - exit 1 -} - - -eos_IconGrasp() { - local app desktop icon - - for app in "$@" ; do - icon=$(eos-FindAppIcon "$app") - #[ -z "$icon" ] && icon=$(yad-tools -i "$app") - #[ -z "$icon" ] && icon=$(yad-tools -i "$(eos-FindAppIcon "$app")") - if [ -n "$icon" ] ; then - echo "$icon" - return 0 - fi - done - - return 1 - - # old stuff - for app in "$@" ; do - desktop=$(/usr/bin/find /usr/share/applications -name \*$app\*\.desktop | /usr/bin/head -n1) - icon=$(/usr/bin/grep ^Icon= "$desktop" 2>/dev/null | /usr/bin/cut -d '=' -f2 | /usr/bin/head -n1) - if [ -n "$icon" ] ; then - echo "$icon" - return - fi - done - return 1 -} - - -# Icons for various use cases like -# --field=... -# --image=... - -export WELCOME_ICON_SYSTEM_LOGS=search # face-worried -export WELCOME_ICON_LEAVE=stop # face-crying -export WELCOME_ICON_HONEST=face-angel - -export WELCOME_ICON_INSTALL_TAB=system-software-update # $(eos_IconGrasp system-software-install) -export WELCOME_ICON_PARTITION_MANAGER=partitionmanager # $(eos_IconGrasp gparted) -export WELCOME_ICON_BLUETOOTH=/usr/share/icons/breeze/preferences/32/preferences-system-bluetooth.svg # $(eos_IconGrasp bluetooth) -export WELCOME_ICON_TOGGLE_r8169_DRIVER=network-wired # $(eos_IconGrasp system-software-update) - -export WELCOME_ICON_CHANGE_RESOLUTION=video-display -export WELCOME_ICON_CHANGE_DISPLAY_MANAGER=video-display -export WELCOME_ICON_INSTALL_OFFICIAL=calamares -export WELCOME_ICON_INSTALL_COMMUNITY=calamares -export WELCOME_ICON_INSTALL_INFO=$WELCOME_ICON_INSTALL_TAB -export WELCOME_ICON_MIRROR_UPDATE=system-software-update # or applications-internet ? -export WELCOME_ICON_BLUETOOTH_INFO=$WELCOME_ICON_BLUETOOTH -export WELCOME_ICON_LATEST_RELEASE=data-information # or info ? -export WELCOME_ICON_INSTALLATION_TIPS=data-information -export WELCOME_ICON_SYSTEM_RESCUE=data-information -export WELCOME_ICON_SYSTEM_LOGS_HOWTO=data-information -export WELCOME_ICON_WEBSITE=data-information # or info ? -export WELCOME_ICON_WIKI=data-information -export WELCOME_ICON_NEWS=data-information -export WELCOME_ICON_FORUM=data-information -export WELCOME_ICON_DONATE=data-information -export WELCOME_ICON_ABOUT_WELCOME=data-information -export WELCOME_ICON_SYSTEM_UPDATE=system-software-update -export WELCOME_ICON_PACCACHE_SRV=applications-system -export WELCOME_ICON_UPDATE_NOTIFIER_CONF=preferences-system -export WELCOME_ICON_WALLPAPER_SET_DEFAULT=preferences-desktop-wallpaper -export WELCOME_ICON_WALLPAPER_SET=preferences-desktop-wallpaper -export WELCOME_ICON_WALLPAPER_DOWNLOAD=preferences-desktop-wallpaper -export WELCOME_ICON_XFCE_THEME_VANILLA=preferences-desktop-theme -export WELCOME_ICON_XFCE_THEME_EOS=preferences-desktop-theme -export WELCOME_ICON_INITIAL_TAB=preferences-system -export WELCOME_ICON_EOS_GENERIC=endeavouros-icon -export WELCOME_ICON_TIPS=data-information -export WELCOME_ICON_ARM=system-run -export WELCOME_ICON_RUNINTERMINAL=preferences-system -export WELCOME_ICON_QUESTION=dialog-question -export WELCOME_ICON_INFO=data-information -export WELCOME_ICON_PREFERENCES=preferences-system # was: system-preferences -export WELCOME_ICON_OWN_COMMANDS=applications-other -export WELCOME_ICON_HELP=help-about -export WELCOME_ICON_ERROR=dialog-error -export WELCOME_ICON_WARNING=dialog-warning -export WELCOME_ICON_APPDEV=applications-development -export WELCOME_ICON_CHANGELOG=applications-development -export WELCOME_ICON_HELP_CONTENTS=help-contents -export WELCOME_ICON_NOTIFICATIONS=process-working -export WELCOME_ICON_NOTIFICATIONS_DISABLED=process-stop - -eos_GetArch() { - local arch; arch="$(/usr/bin/uname -m)" - case "$arch" in - armv7* | aarch64) arch=armv7h ;; - esac - printf "%s" "$arch" -} - -eos_GetProgName() { /usr/bin/basename "$0" ; } - -eos_select_browser() { - # Select an existing browser. - # User may export a variable _WELCOME_BROWSER to use the preferred browser. - # Additionally, variable _WELCOME_BROWSER_OPTIONS may include browser options. - - if [ -n "$_WELCOME_BROWSER" ] ; then - if [ -n "$_WELCOME_BROWSER_OPTIONS" ] ; then - echo "$_WELCOME_BROWSER $_WELCOME_BROWSER_OPTIONS" - else - echo "$_WELCOME_BROWSER" - fi - return - fi - - # If _WELCOME_BROWSER is not exported, use the user configurable list of browsers - # in file /etc/eos-script-lib-yad.conf - - local old_list="xdg-open exo-open firefox chromium vivaldi-stable opera" # for backwards compatibility - local browser - - for browser in "${EOS_PREFERRED_BROWSERS[@]}" $old_list - do - if (/usr/bin/which "$browser" >& /dev/null) ; then - echo "$browser" - return - fi - done - eos_yad_WARN "${FUNCNAME[0]}: cannot find a browser" -} - -eos_notification() { # sending notification to the current user - local icon="$1" - local urgency="$2" # low, normal, critical - local expiretime="$3" - local appname="$4" - local summary="$5" - local body="$6" - local action="$7" - [ -n "$urgency" ] || urgency=normal - - local cmd=( - notify-send - --icon="$icon" - --urgency="$urgency" - --expire-time="$expiretime" - --app-name="$appname" - "$summary" - "$body" - ) - if [ -n "$action" ] ; then - cmd+=(--action="$action") - fi - "${cmd[@]}" -} - -eos_notification_all() { # sending notification to all users - eos_GetUsers() { /usr/bin/users | sed 's| |\n|g' | sort -u ; } - - local icon="$1" - local urgency="$2" # low, normal, critical - local expiretime="$3" # milliseconds - local appname="$4" - local summary="$5" # title - local body="$6" # msg - local body_to_tty="$7" # action not supported! - - [ -n "$urgency" ] || urgency=normal - - [ "$body_to_tty" = "yes" ] && echo "==> INFO: $body" >&2 # meant to print to TTY - - local users=() user userid - local cmd=() - - readarray -t users <<< $(eos_GetUsers) - - for user in "${users[@]}" ; do - userid=$(/usr/bin/id -u "$user") - cmd=( - DISPLAY=:0 - DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$userid/bus - notify-send - --icon="$icon" - --urgency="$urgency" - --expire-time="$expiretime" - --app-name="$appname" - "'$summary'" - "'$body'" - ) - /usr/bin/su "$user" -c "${cmd[*]}" - done -} - -eos_yad_terminal() { - local conf=/etc/eos-script-lib-yad.conf - if [ -r $conf ] ; then - source $conf - if [ -n "$EOS_YAD_TERMINAL" ] ; then - if [ -x /usr/bin/"$EOS_YAD_TERMINAL" ] || [ -x "$EOS_YAD_TERMINAL" ] ; then - echo "$EOS_YAD_TERMINAL" - return - fi - echo "Sorry, terminal program '$EOS_YAD_TERMINAL' is not available. Please check your configuration file $conf." | \ - eos_yad --text-info --title=Warning --height=100 --width=500 --wrap --button=yad-ok:0 - fi - fi - - # Show a terminal that is capable of supporting option -e properly. Empty if not found. - # Requires: yad - # - # These terminal programs are known not to work with this program: - # - putty - # The following terminals are known to work: - local suitable_terminals=( - xfce4-terminal - konsole - gnome-terminal - mate-terminal - lxterminal - deepin-terminal - terminator - qterminal - alacritty - tilix - termite - xterm - kitty - terminology - sakura - ) - local eos_terminal_prog="" - local xx - - for xx in "${suitable_terminals[@]}" ; do - if [ -x "/usr/bin/$xx" ] ; then - eos_terminal_prog="/usr/bin/$xx" - echo "$eos_terminal_prog" - return 0 - fi - done - - printf "%s\n %s\n%s" \ - "Sorry, none of the terminal programs:" \ - "${suitable_terminals[*]}" \ - "is installed. Some features may not work as expected." \ - | eos_yad --text-info \ - --title="Warning" --height=200 --width=700 --wrap --button=yad-ok:0 - return 1 -} - -eos_yad_check_internet_connection() { - local verbose="$1" # yes|verbose = show dialog, otherwise don't show dialog - local waitrounds="$2" # try max $waitrounds times for a connection, test once per $onewait - local onewait="$3" # time to wait in one waiting round - local caller="$4" # who is calling this function (often empty) - local ix - local title="Warning" - local checker="ping -c 1 8.8.8.8" - - case "$EOS_CONNECTION_CHECKER" in - curl) - # checker="curl --silent --connect-timeout 8 https://8.8.8.8" - checker=eos-connection-checker - ;; - esac - - test -z "$verbose" && verbose=no - test -z "$waitrounds" && waitrounds=5 - test -z "$onewait" && onewait=1s - - if [ -n "$caller" ] ; then - title+=" from $caller" - fi - - for ((ix=0; ix/dev/null && return 0 # is connected - sleep $onewait - done - - $checker >/dev/null || { - case "$verbose" in - [yY]*|1|true|TRUE|True|on|enable*|verbose) - if [ 0 -eq 1 ] ; then - echo "No internet connection!" | \ - eos_yad --text-info --title="$title" \ - --height=100 --width=300 --justify=center --wrap \ - --button=yad-quit:1 \ - --button=" Continue anyway!go-next!Don't stop me now":0 - else - eos_notification "$WELCOME_ICON_WARNING" normal 60000 "$caller" "$title" "No internet connection!" - fi - ;; - *) - return 1 - ;; - esac - } -} - -eos_yad_GetArgVal() { echo "${1#*=}" ; } - -eos_yad_RunCmdTermBashOpt() { # like eos_yad_RunCmdTermBash, but supports certain options - local cmd="" - local prompt="" - local termopts="" - local waitopt="" - local opts - local retval - - # Handle options for variables cmd ... waitopt. - opts="$(getopt -o=p:t:w:E --longoptions prompt:,term:,wait:,no-enter-wait --name "${FUNCNAME[0]}" -- "$@")" - retval=$? - [ $retval -eq 0 ] || return 1 - eval set -- "$opts" - while true ; do - case "$1" in - --prompt | -p) - prompt="$2" ; shift ;; - --term | -t) - termopts="$2" ; shift ;; # e.g. --term="-T 'my title' --geometry=100x200" - --wait | -w) - waitopt="$2" ; shift ;; # either --wait="--no-enter-wait" or --wait="sleep=30" (30 (seconds) can be something else too) - --no-enter-wait | -E) - waitopt="--no-enter-wait" ;; # alternative to --wait - --) - shift; break ;; - esac - shift - done - cmd="$*" - [ -n "$cmd" ] || { echo "${FUNCNAME[0]}: warning: required command is missing." >&2; return 1; } - - # Get the available/configured terminal. - local term; term="$(eos_yad_terminal)" - test -n "$term" || return 1 - - mkdir -p "$HOME/.cache" - local tmpfile; tmpfile=$(mktemp "$HOME/.cache/${FUNCNAME[0]}.XXXXX") - - trap "sleep 0.2; rm -f '$tmpfile'" EXIT - - echo "#!/bin/bash" >> "$tmpfile" - test -n "$prompt" && echo "echo $prompt" >> "$tmpfile" - echo "$cmd" >> "$tmpfile" - echo "echo" >> "$tmpfile" - case "$term" in - /usr/bin/deepin-terminal | deepin-terminal) ;; - *) - _init_translations - case "$waitopt" in - --no-enter-wait | no-enter-wait) ;; - sleep=*) - local waittime="${waitopt#*=}" - echo "eos-sleep-counter $waittime" >> "$tmpfile" - ;; - *) - echo "read -p '$(ltr updt_press_enter): '" >> "$tmpfile" - ;; - esac - ;; - esac - echo "rm -f $tmpfile" >> "$tmpfile" # this may cause issues in very special cases! - - chmod +x "$tmpfile" - - # Try make sure terminal $term does not return to the caller immediately - # but waits until the commands from $tmpfile are executed. - case "$term" in - /usr/bin/gnome-terminal | gnome-terminal) - $term $termopts --wait -- "$tmpfile" ;; - /usr/bin/xfce4-terminal | xfce4-terminal) - $term --disable-server $termopts -e "$tmpfile" ;; - *) - $term $termopts -e "$tmpfile" ;; - esac - - # The following DOES NOT WORK with plain gnome-terminal: - #echo "Deleting '$tmpfile'." - #rm -f "$tmpfile" -} - -eos_yad_RunCmdTermBash() { - local cmd="$1" - local prompt="$2" - local termopts="$3" - local waitopt="$4" - - eos_yad_RunCmdTermBashOpt --prompt="$prompt" --term="$termopts" --wait="$waitopt" "$cmd" -} - -eos_yad_problem() { - local title="$1" - shift - eos_yad --text-info --title="$title" --wrap --image=$WELCOME_ICON_ERROR \ - --width=700 --height=500 --button=yad-quit:0 "$@" - # removed --tail -} - -eos_yad_DIE() { - # This function is only for small messages. - # The local Usage can be used only if it is - # - defined before sourcing this file - # - exported - - local msg="$1" - local title="Error" - shift - while true ; do - echo "$msg" - # run Usage function if available (usually is not ...) - test -n "$(declare -F | grep -w '^declare -f Usage$')" && Usage - break - done | eos_yad_problem "$title" "$@" - exit 1 -} - -eos_yad_WARN() { - local msg="$1" - local title="Warning" - shift - echo "$msg" | eos_yad_problem "$title" --image=$WELCOME_ICON_WARNING "$@" -} - -# Function detectDE is copied from: https://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-utils-common.in - -#-------------------------------------- -# Checks for known desktop environments -# set variable DE to the desktop environments name, lowercase - -eos_yad__detectDE() -{ - # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 - unset GREP_OPTIONS - - if [ -n "${XDG_CURRENT_DESKTOP}" ]; then - case "${XDG_CURRENT_DESKTOP}" in - # only recently added to menu-spec, pre-spec X- still in use - Budgie*) - DE=budgie - ;; - Cinnamon|X-Cinnamon) - DE=cinnamon; - ;; - DEEPIN|[Dd]eepin) - DE=deepin; - ;; - ENLIGHTENMENT|Enlightenment) - DE=enlightenment; - ;; - # GNOME, GNOME-Classic:GNOME, or GNOME-Flashback:GNOME - GNOME*|gnome) - DE=gnome; - ;; - KDE) - DE=kde; - ;; - LXDE) - DE=lxde; - ;; - LXQt) - DE=lxqt; - ;; - MATE) - DE=mate; - ;; - XFCE) - DE=xfce - ;; - X-Generic) - DE=generic - ;; - i3) - DE=i3 - ;; - esac - fi - - if [ "$DE" = "" ]; then - # classic fallbacks - if [ x"$KDE_FULL_SESSION" != x"" ]; then DE=kde; - elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; - elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate; - elif dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager &>/dev/null ; then DE=gnome; - elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; - elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce - elif echo "$DESKTOP" | grep -q '^Enlightenment'; then DE=enlightenment; - elif [ x"$LXQT_SESSION_CONFIG" != x"" ]; then DE=lxqt; - fi - fi - - if [ "$DE" = "" ]; then - # fallback to checking $DESKTOP_SESSION - case "$DESKTOP_SESSION" in - gnome) - DE=gnome; - ;; - LXDE|Lubuntu) - DE=lxde; - ;; - MATE) - DE=mate; - ;; - xfce|xfce4|'Xfce Session') - DE=xfce; - ;; - openbox) - DE=openbox - ;; - esac - fi - - if [ "$DE" = "" ]; then - # fallback to uname output for other platforms - case "$(uname 2>/dev/null)" in - CYGWIN*) - DE=cygwin; - ;; - Darwin) - DE=darwin; - ;; - esac - fi - - if [ "$DE" = "gnome" ]; then - # gnome-default-applications-properties is only available in GNOME 2.x - # but not in GNOME 3.x - : - # which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3" # This is no more needed (?) - fi - - if [ -f "$XDG_RUNTIME_DIR/flatpak-info" ]; then - DE="flatpak" - fi - - if [ -z "$DE" ] ; then - if [ -x /usr/bin/qtile ] && [ -d /usr/share/doc/qtile ] ; then - DE="qtile" - fi - fi - if [ -z "$DE" ] ; then - if eos_IsSway ; then - DE=sway - elif eos_IsBspwm ; then - DE=bspwm - fi - fi - - if [ -z "$DE" ] ; then - # neofetch fails: Enlightenment, openbox - # neofetch differs: KDE -> plasma (with DESKTOP_SESSION=openbox-kde and DESKTOP_SESSION=plasma) - [ -x /usr/bin/neofetch ] && DE="$(neofetch --enable de --de_version off | awk '{print $NF}' | tr '[:upper:]' '[:lower:]')" - fi -} - -# These 2 funcs return the DE/WM in upper case letters: -eos_yad_GetDesktopName() { # return DE name in uppercase letters - eos_yad__detectDE - echo "$DE" | tr '[:lower:]' '[:upper:]' -} -eos_GetDeOrWm() { eos_yad_GetDesktopName ; } - -eos_IsSway() { - case "$DESKTOP_SESSION" in - sway | */sway) return 0 ;; - esac - case "$XDG_SESSION_DESKTOP" in - sway | */sway) return 0 ;; - esac - [ -x /usr/bin/swaybg ] && return 0 - return 1 -} - -eos_IsBspwm() { - case "$DESKTOP_SESSION" in - bspwm | */bspwm) return 0 ;; - esac - case "$XDG_SESSION_DESKTOP" in - bspwm | */bspwm) return 0 ;; - esac - [ -x /usr/bin/bspwm ] && return 0 - return 1 -} - -# DIE() { eos_yad_DIE "$@" ; } # deprecated -# WARN() { eos_yad_WARN "$@" ; } # deprecated - -#SetBrowser() { -# local xx -# for xx in xdg-open exo-open firefox chromium ; do # use one of these browser commands -# if [ -x /usr/bin/$xx ] ; then -# _BROWSER=/usr/bin/$xx # for showing external links -# return -# fi -# done -# DIE "${FUNCNAME[0]}: cannot find a browser" -#} - -eos_yad_nothing_todo() { - local text="$1" - local timeout="$2" # optional, default set below - local title="$3" # optional, default set below - local image="$4" # optional, default set below - - [ -n "$timeout" ] || timeout=10 - [ -n "$title" ] || title="Info" - [ -n "$image" ] || image=data-information - - local cmd=( - eos_yad --form --text="$text" --title="$title" --no-focus --image="$image" - --height=100 --width=300 --timeout="$timeout" --timeout-indicator=left - --button=yad-close:0 - ) - "${cmd[@]}" -} - - -FindAvailableMonoFont() { - local size="$1" - local font="Mono" # fallback - - [ -n "$size" ] || size=10 - - if [ -r /usr/share/fonts/liberation/LiberationMono-Regular.ttf ] ; then - font="Liberation Mono" - elif [ -r /usr/share/fonts/TTF/DejaVuSansMono.ttf ] ; then - font"DejaVu Sans Mono" - elif [ -r /usr/share/fonts/noto/NotoSansMono-Regular.ttf ] ; then - font="Noto Sans Mono" - elif [ -r /usr/share/fonts/gsfonts/NimbusMonoPS-Regular.otf ] ; then - font="Nimbus Mono" - elif [ -r /usr/share/fonts/adobe-source-code-pro/SourceCodePro-Regular.otf ] ; then - font="Source Code Pro" - fi - echo "$font $size" -} - -ProgressBar() { # This function was converted from the work of @Kresimir, thanks! - local msg="$1" - local percent="$2" - local barlen="$3" - local c - local columns="$COLUMNS" # nr of columns on the terminal - [ -n "$columns" ] || columns=80 # guess nr of columns on the terminal - local msglen=$((columns - barlen - 9)) # max space for the msg - [ "${#msg}" -gt "$msglen" ] && msg="${msg::$msglen}" # msg must be truncated - [ "${msg: -1}" = ":" ] || msg+=":" # make sure a colon is after msg - - printf "\r%-*s %3d%% [" "$msglen" "$msg" "$percent" >&2 - for ((c = 0; c < barlen; c++)) ; do - if (( c <= percent * barlen / 100 )); then - echo -ne "#" >&2 - else - echo -ne " " >&2 - fi - done; - stdbuf -oL printf "]" >&2 # flush stdout -} -ProgressBarInit() { - # progress bar initialization - trap 'printf "\x1B[?25h" >&2' EXIT # cursor on - printf "\x1B[?25l" >&2 # cursor off -} -ProgressBarEnd() { - printf "\n" >&2 -} - -YadProgressPulsate() { - local lockfile="$1" - local text="$2" - - while true ; do - [ -r "$lockfile" ] || return - echo 0 - sleep 0.1s - done | eos_yad --progress \ - --title="Progress indicator" \ - --text="$text" \ - --auto-close \ - --width=400 --hide-text --pulsate -} - -eos_FormMonoText() { - local txt="$1" - local size="$2" # optional - - [ -n "$size" ] && size=" $size" - printf "%s" "$txt" -} - - -Wget2Curl() { - # Convert a wget call to a curl call. - local opts - # shellcheck disable=SC2154 # don't complain about undefined $progname - local _progname="$progname" # $progname may come from the user app - [ -n "$_progname" ] || _progname="$(eos_GetProgName)" - - opts="$(/usr/bin/getopt -o=qO: --longoptions timeout:,user-agent: --name "$_progname" -- "$@")" || { - PreLog "${FUNCNAME[0]}: option handling failed!" - return 1 - } - - eval set -- "$opts" - - local cmd=(curl --fail --location) - local retval=0 - - while true ; do - case "$1" in - -q) cmd+=(--silent) ;; - -O) cmd+=(--output "$2"); shift ;; - --user-agent) cmd+=(--user-agent "$2"); shift ;; - --timeout) cmd+=(--max-time "$2"); shift ;; - - --) shift ; break ;; - esac - shift - done - - # [ "$foobar_test" = "yes" ] && echo "${cmd[*]} $*" - - "${cmd[@]}" "$@" - - retval=$? - #if [ "$foobar_test" = "yes" ] ; then - # case "$retval" in - # 23) echo "==> Write error. Curl could not write data to a local filesystem or similar." ;; - # 0) ;; - # *) echo "==> curl returned $retval." ;; - # esac - #fi - return $retval -} - - -eos_is_installing() { - if [ "$LOGNAME" = "liveuser" ] || [ "$USER" = "liveuser" ] ; then - if [ -x /usr/bin/calamares ] ; then - return 0 # installing - fi - fi - return 1 # not installing -} - -# check the config: -if eos_is_installing ; then - export EOS_ROOTER="sudo bash -c" -else - case "$EOS_ROOTER" in - su | "su -c" | "/usr/bin/su -c" | "") export EOS_ROOTER="eos-run-cmd-with-su" ;; # default! - sudo | "sudo bash -c" | "/usr/bin/sudo bash -c") export EOS_ROOTER="sudo bash -c" ;; - pkexec | "pkexec bash -c" | "/usr/bin/pkexec bash -c") export EOS_ROOTER="/usr/bin/pkexec bash -c" ;; - su-c_wrapper) export EOS_ROOTER="/usr/bin/su-c_wrapper bash -c" ;; - *) - eos_yad_DIE "Error: configuration '$EOS_ROOTER' for EOS_ROOTER in file /etc/eos-script-lib-yad.conf is not supported!" - ;; - esac -fi - -eos_running_kernel() { - # Output the name of the running kernel, e.g. 'linux-lts'. - # If unable to determine the running kernel, output nothing. - # Note the alternative (fallback) implementations below. - - local running_kernel="" - local pkgbase="/usr/lib/modules/$(uname --kernel-release)/pkgbase" - - if [ -r "$pkgbase" ] ; then - running_kernel="$(cat "$pkgbase")" - case "$running_kernel" in - linux*) echo "$running_kernel" ; return ;; - esac - fi - - if [ -r /proc/version ] ; then - running_kernel="$(cat /proc/version | sed 's|.*(\([^@]*\)@archlinux).*|\1|')" - case "$running_kernel" in - linux*) echo "$running_kernel" ; return ;; - esac - fi - - if [ -r /proc/cmdline ] ; then - running_kernel=$(cat /proc/cmdline | awk '{print $1}' | sed 's|^.*/vmlinuz-\(.*\)$|\1|') # works only with grub - case "$running_kernel" in - linux*) echo "$running_kernel" ; return ;; - esac - fi -}