mirror of
https://github.com/endeavouros-team/eos-bash-shared.git
synced 2026-06-13 01:34:36 +00:00
source code moved here from PKGBUILDS
This commit is contained in:
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: ChangeDisplayResolution [resolution]
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || {
|
||||
echo "Error: ${BASH_SOURCE[1]}, line $LINENO: cannot find /usr/share/endeavouros/scripts/eos-script-lib-yad" >&2
|
||||
exit 1
|
||||
}
|
||||
export -f eos_yad
|
||||
|
||||
DIE() {
|
||||
echo "$progname: error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Restart_me() {
|
||||
local tmpfile=$(mktemp)
|
||||
cat <<EOF > $tmpfile
|
||||
#!/bin/bash
|
||||
pkill "$progname"
|
||||
sleep 0.1
|
||||
"$progname" &
|
||||
EOF
|
||||
bash $tmpfile
|
||||
sleep 2
|
||||
rm -f $tmpfile
|
||||
}
|
||||
export -f Restart_me
|
||||
|
||||
yad_ChangeDisplayResolution() {
|
||||
local reso="$1"
|
||||
local progname="${BASH_SOURCE[1]}" # "$(basename $0)"
|
||||
if ! type xrandr >& /dev/null ; then
|
||||
DIE "this implementation needs package 'xorg-xrandr'."
|
||||
fi
|
||||
local query="$(xrandr --query)"
|
||||
local output="$(echo "$query" | grep " connected " | head -n 1 | awk '{print $1}')"
|
||||
local xrandr="xrandr --output $output --mode"
|
||||
local resos="$(echo "$query" | grep "^ [ ]*[0-9][0-9]*x[0-9][0-9]* " | awk '{print $1}')"
|
||||
local resosarr
|
||||
local current_reso="$(echo "$query" | grep "^ [ ]*[0-9][0-9]*x[0-9][0-9]* " | grep "*" | awk '{print $1}')"
|
||||
local retval
|
||||
local result
|
||||
local txt mark="*"
|
||||
local impl=list # list or form
|
||||
local butt_set_quit="Set and quit"
|
||||
local butt_set_stay="Set and stay"
|
||||
|
||||
# yad window return values must be different:
|
||||
local b_ok=0 # button "Set and quit" clicked
|
||||
local b_quit=1 # button "Quit" clicked (button currently not visible!)
|
||||
local b_refresh=10 # button "Set and stay" clicked
|
||||
local b_exit=252 # (X) clicked in the upper right corner
|
||||
|
||||
readarray -t resosarr <<< $(echo "$resos")
|
||||
|
||||
if [ -n "$reso" ] ; then
|
||||
if [ -n "$(echo "$resos" | grep "$reso")" ] ; then
|
||||
$xrandr "$reso"
|
||||
else
|
||||
echo "Error: $progname: given resolution '$reso' is not supported." >&2
|
||||
echo "Supported values:" >&2
|
||||
for reso in "${resosarr[@]}" ; do
|
||||
if [ "$reso" = "$current_reso" ] ; then
|
||||
echo " * $reso"
|
||||
else
|
||||
echo " $reso"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
txt="Select new display resolution from the list below.\n"
|
||||
txt+="- Current value is marked with: <b>$mark</b>\n"
|
||||
txt+="- Double clicking a value does <b>$butt_set_quit</b>\n"
|
||||
|
||||
local cmd=(
|
||||
eos_yad
|
||||
--image=preferences-desktop-display
|
||||
--width=400
|
||||
--title="Change display resolution"
|
||||
--text="$txt"
|
||||
)
|
||||
|
||||
case "$impl" in
|
||||
form) cmd+=(--form --columns=2 --button=yad-quit:0) ;;
|
||||
list) cmd+=(--list --height=500 --no-click --grid-lines=both
|
||||
--column="Available resolution values:"
|
||||
# --button="yad-quit!!Change nothing, just quit":$b_quit
|
||||
--button="$butt_set_stay!view-refresh!Use selected resolution but don't quit":$b_refresh
|
||||
--button="$butt_set_quit!gtk-ok!Use selected resolution and quit":$b_ok
|
||||
) ;;
|
||||
esac
|
||||
for reso in "${resosarr[@]}" ; do
|
||||
if [ "$reso" = "$current_reso" ] ; then
|
||||
case "$impl" in
|
||||
form) cmd+=(--field="* $reso":fbtn "$xrandr $reso") ;;
|
||||
list) cmd+=("$reso $mark") ;;
|
||||
esac
|
||||
else
|
||||
case "$impl" in
|
||||
form) cmd+=(--field=" $reso":fbtn "$xrandr $reso") ;;
|
||||
list) cmd+=("$reso") ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
result="$("${cmd[@]}")"
|
||||
retval=$?
|
||||
if [ -z "$result" ] ; then
|
||||
return
|
||||
fi
|
||||
case "$retval" in
|
||||
$b_quit | $b_exit) return ;;
|
||||
esac
|
||||
|
||||
case "$impl" in
|
||||
form) ;; # does not support refresh...
|
||||
list)
|
||||
reso="$(echo "$result" | cut -d '|' -f 1 | awk '{print $1}')"
|
||||
if [ -n "$(echo "$reso" | tr -d '0-9x')" ] ; then
|
||||
echo "Invalid resolution value '$reso'" >&2
|
||||
return 1
|
||||
fi
|
||||
$xrandr $reso
|
||||
case "$retval" in
|
||||
$b_refresh) Restart_me ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
yad_ChangeDisplayResolution "$@"
|
||||
@@ -1,2 +1,28 @@
|
||||
# eos-bash-shared
|
||||
|
||||
Source code for the eos-bash-shared package
|
||||
|
||||
## Purpose of these apps and files
|
||||
|
||||
Code shared between EndeavourOS apps, and certain small but useful tools.
|
||||
|
||||
File name | Description
|
||||
:---- | :-------
|
||||
ChangeDisplayResolution | Helps changing display resolution (with xrandr).
|
||||
device-info | A helper app for finding info about devices.
|
||||
eos-connection-checker | Checks that an internet connection is available.
|
||||
eos-FindAppIcon | Find a suitable icon path for an app.
|
||||
eos-pkg-changelog | (Unavailable) Show the changelog of (most) EndeavourOS packages.<br>Usage: `eos-pkg-changelog <package-name>`
|
||||
eos-pkginfo | (Unavailable) Show usage and/or developer information about an EndeavourOS/Arch/AUR package.<br>Package can be identified by its name, included program, or file path.<br>Usage: `eos-pkginfo {<package-name> \| <program-name> \| <file path>`}
|
||||
eos-pkginfo.completion | (Unavailable) Bash completion for eos-pkginfo.<br>Note: does not support completion for AUR packages because of performance.
|
||||
eos-script-lib-yad | Common bash code for various EOS apps.
|
||||
eos-script-lib-yad.conf | Configuration file for eos-script-lib-yad.
|
||||
eos-sendlog | Send a text file to pastebin, and save the returned URL to ~/.config/eos-sendlog.txt.<br>Example: `cat log.txt \| eos-sendlog`
|
||||
eos-wallpaper-set | Sets the wallpaper according to the current DE, given file, or from given folder.
|
||||
ksetwallpaper.py | KDE wallpaper installer, forked from https://github.com/pashazz/ksetwallpaper.
|
||||
paccache-service-manager | Tool to manage paccache service (prevents package cache size growing too much).
|
||||
RunInTerminal | Run one or many commands in a new terminal. Useful for Welcome and related apps.
|
||||
su-c_wrapper | A small utility to perform command "su -c". Useful e.g. for users without sudoers rights.<br> Tip: make a short alias, for example: `alias root=su-c_wrapper`
|
||||
UpdateInTerminal | Simple system updater using only terminal.
|
||||
UpdateInTerminal.desktop | Launcher & icon for UpdateInTerminal.
|
||||
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a command in a terminal.
|
||||
# See also: RunInTerminalEx
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || {
|
||||
echo "Error: cannot source eos-script-lib-yad" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export -f eos_yad_terminal
|
||||
export -f eos_yad_RunCmdTermBash
|
||||
export -f eos_yad
|
||||
|
||||
Main()
|
||||
{
|
||||
eos_yad_RunCmdTermBash "$*"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a command in terminal.
|
||||
# See also: RunInTerminal
|
||||
# Note: this is supposed to be more "fail safe" with parameters than RunInTerminal.
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || {
|
||||
echo "Error: cannot source eos-script-lib-yad" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export -f eos_yad_terminal
|
||||
export -f eos_yad_RunCmdTermBash
|
||||
export -f eos_yad
|
||||
|
||||
Main()
|
||||
{
|
||||
local xx cmd=""
|
||||
|
||||
for xx in "$@" ; do
|
||||
case "" in
|
||||
-*) cmd+="$xx " ;;
|
||||
*) cmd+="'$xx' " ;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
eos_yad_RunCmdTermBash "$cmd"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a command in terminal.
|
||||
# See also: RunInTerminal
|
||||
#
|
||||
# This one supports these options:
|
||||
# - Give a prompt for the user
|
||||
# --prompt <prompt-string>
|
||||
# - Give terminal options
|
||||
# --term <terminal-options-string>
|
||||
# - Don't require user to press ENTER key to close the terminal window
|
||||
# --no-enter-wait
|
||||
# - Stop parsing more parameters
|
||||
# --
|
||||
#
|
||||
# Examples:
|
||||
# - Simple command
|
||||
# RunInTerminalOpt pwd
|
||||
# - If command has options, use -- to stop parsing
|
||||
# RunInTerminalOpt -- ls -la
|
||||
# - Run multiple commands
|
||||
# RunInTerminalOpt -- bash -c "pwd ; ls -la"
|
||||
# - If file name has spaces, use baskslash (\) to quote space
|
||||
# RunInTerminalOpt -- bash -c "pwd ; ls -la foo\ bar" # needs file "foo bar" to exist!
|
||||
# - Use an option
|
||||
# RunInTerminalOpt --prompt="Here you are:" -- bash -c "pwd ; ls -la"
|
||||
# - Redirection
|
||||
# RunInTerminalOpt -E "echo '$(date)' > /tmp/foobar"
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || {
|
||||
echo "Error: cannot source eos-script-lib-yad" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export -f eos_yad_terminal
|
||||
export -f eos_yad_RunCmdTermBashOpt
|
||||
export -f eos_yad
|
||||
|
||||
Main()
|
||||
{
|
||||
eos_yad_RunCmdTermBashOpt "$@"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+275
@@ -0,0 +1,275 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo2() { echo "$@" >&2 ; }
|
||||
printf2() { printf "$@" >&2 ; }
|
||||
DIE() { echo2 "$progname: error: $1" ; Usage ; exit 1 ; }
|
||||
WARN() { echo2 "====> $progname: warning: $1" ; }
|
||||
|
||||
translations_dir=/usr/share/endeavouros/scripts # needed in translations.bash
|
||||
|
||||
source $translations_dir/eos-script-lib-yad --limit-icons || {
|
||||
progname="$(basename "$0")"
|
||||
DIE "$translations_dir/eos-script-lib-yad not found!"
|
||||
}
|
||||
source $translations_dir/translations.bash || {
|
||||
progname="$(basename "$0")"
|
||||
DIE "$translations_dir/translations.bash not found!"
|
||||
}
|
||||
|
||||
export -f eos_yad_terminal
|
||||
export -f eos_yad_RunCmdTermBash
|
||||
|
||||
GrubCheckFwsetup() {
|
||||
if [ -d /sys/firmware/efi ] ; then # have uefi
|
||||
if [ -x /usr/bin/grub-mkconfig ] ; then # have grub
|
||||
local updates="$1"
|
||||
if [ -n "$(echo "$updates" | grep -w grub)" ] ; then
|
||||
local version_requiring_fwsetup="2:2.06.r322.gd9b4638c5-1"
|
||||
local curver ; curver="$(pacman -Q grub 2>/dev/null | awk '{print $NF}')"
|
||||
if [ "$(vercmp "$curver" "$version_requiring_fwsetup")" -lt "0" ] ; then
|
||||
cat <<EOF >&2
|
||||
|
||||
==> IMPORTANT: you will have to run grub-install BEFORE reboot!
|
||||
|
||||
Example:
|
||||
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=EndeavourOS-grub
|
||||
|
||||
See https://forum.endeavouros.com/t/the-latest-grub-package-update-needs-some-manual-intervention
|
||||
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Checkupdates() {
|
||||
# Variables:
|
||||
# in: updates
|
||||
# out: updates
|
||||
|
||||
local retval
|
||||
|
||||
if [ -n "$ufile" ] ; then
|
||||
updates=$(cat "$ufile")
|
||||
if [ -n "$(echo "$updates" | grep "Download Size")" ] ; then
|
||||
updates=$(echo "$updates" | tail -n +3)
|
||||
fi
|
||||
retval=0
|
||||
else
|
||||
updates=$(checkupdates)
|
||||
retval=$?
|
||||
fi
|
||||
|
||||
echo "$updates"
|
||||
updates="$(echo "$updates" | awk '{print $1}')"
|
||||
|
||||
GrubCheckFwsetup "$updates"
|
||||
|
||||
case "$retval" in
|
||||
0)
|
||||
eos-kernel-nvidia-update-check $updates || {
|
||||
read -p "Stop upgrade (Y/n)? " >&2
|
||||
case "$REPLY" in
|
||||
"" | [Yy]*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
;;
|
||||
esac
|
||||
return $retval
|
||||
}
|
||||
|
||||
OptionsHandler() {
|
||||
IsBashFunction() {
|
||||
[ "$(LANG=C type "$1" 2>/dev/null | head -n1 | awk '{print $NF}')" = "function" ]
|
||||
}
|
||||
|
||||
if [ -z "$progname" ] ; then
|
||||
local progname ; progname="$(/usr/bin/basename "$0")"
|
||||
fi
|
||||
local sopts="$1"
|
||||
local lopts="$2"
|
||||
local OptFunc="$3"
|
||||
local opts
|
||||
shift 3
|
||||
|
||||
if [ -z "$sopts" ] || [ -z "$lopts" ] || [ -z "$OptFunc" ] ; then
|
||||
echo "$progname: parameter(s) missing" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! IsBashFunction "$OptFunc" ; then
|
||||
echo "$progname: parameter OptFunc is not a bash function" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
opts="$(/usr/bin/getopt -o="$sopts" --longoptions "$lopts" --name "$progname" -- "$@")" || {
|
||||
$OptFunc -h
|
||||
return 1
|
||||
}
|
||||
|
||||
eval set -- "$opts"
|
||||
|
||||
$OptFunc "$@"
|
||||
}
|
||||
|
||||
MyOptions() {
|
||||
local pp
|
||||
while true ; do
|
||||
pp="$1"
|
||||
case "$1" in
|
||||
--noup) checkArchEos=no ;;
|
||||
--noaur) checkAur=no ;;
|
||||
--nt) new_terminal=yes ;;
|
||||
--sync) allow_sync=yes ;;
|
||||
--keyring) keyring_first=yes ;;
|
||||
--lang) new_terminal_options+=" $pp=$2" ; lang="$2" ; shift ;;
|
||||
--updates) new_terminal_options+=" $pp=$2" ; ufile="$2" ; shift ;;
|
||||
|
||||
--help | -h) Usage ; return 1 ;;
|
||||
--) shift ; break ;;
|
||||
-*) DIE "unsupported option '$1'" ;;
|
||||
*) DIE "unsupported parameter '$1'" ;;
|
||||
esac
|
||||
case "$pp" in
|
||||
--nt | --lang | --updates) ;;
|
||||
*) new_terminal_options+=" $pp" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
ChecksForKeyrings() {
|
||||
|
||||
# Separate keyring package updates from other updates.
|
||||
# Also make sure that package endeavouros-keyring is installed.
|
||||
|
||||
local arg
|
||||
local eos_keyring=no
|
||||
|
||||
for arg in $updates ; do
|
||||
case "$arg" in
|
||||
archlinux-keyring)
|
||||
krpkg+=("$arg")
|
||||
;;
|
||||
endeavouros-keyring)
|
||||
krpkg+=("$arg")
|
||||
eos_keyring=yes
|
||||
;;
|
||||
*)
|
||||
args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is for old installs that might not have package endeavouros-keyring installed:
|
||||
|
||||
if [ "$eos_keyring" = "no" ] ; then
|
||||
if ! pacman -Qq endeavouros-keyring >& /dev/null ; then
|
||||
echo "==> Installing endeavouros-keyring." >&2
|
||||
krpkg+=(endeavouros-keyring)
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
Usage: $progname [options]
|
||||
Options:
|
||||
--noup Don't check $upname updates.
|
||||
--noaur Don't check AUR updates.
|
||||
--nt Check updates in a new terminal window.
|
||||
--sync Run program 'sync' afterwards if updates were detected.
|
||||
--keyring Update keyring packages first. This may help on some PGP signature issues.
|
||||
EOF
|
||||
}
|
||||
|
||||
Main() {
|
||||
local checkArchEos=yes
|
||||
local checkAur=yes
|
||||
local keyring_first="$EOS_UPDATE_ARCH_KEYRING_FIRST"
|
||||
local lang=""
|
||||
local progname ; progname="$(basename "$0")"
|
||||
local upname="Arch & EndeavourOS"
|
||||
local aur_helper="$EOS_AUR_HELPER"
|
||||
local new_terminal=no
|
||||
local new_terminal_options="" # skips only --nt
|
||||
local updates_found=no
|
||||
local allow_sync=no
|
||||
local updates
|
||||
local args=()
|
||||
local krpkg=()
|
||||
local ufile=""
|
||||
|
||||
cat <<EOF >&2
|
||||
|
||||
Note: '$progname' is deprecated, consider using 'yay', 'paru', or 'pacman' instead.
|
||||
|
||||
EOF
|
||||
|
||||
# make sure we have reasonable values
|
||||
[ -n "$keyring_first" ] || keyring_first=no
|
||||
[ -n "$aur_helper" ] || aur_helper=yay
|
||||
|
||||
OptionsHandler "h" "noup,noaur,lang:,nt,sync,keyring,updates:" MyOptions "$@" || return
|
||||
|
||||
if [ "$new_terminal" = "yes" ] ; then
|
||||
eos_yad_RunCmdTermBash "$progname $new_terminal_options"
|
||||
[ -n "$ufile" ] && rm -f "$ufile"
|
||||
return
|
||||
fi
|
||||
|
||||
_init_translations "$lang" # other parameters as defaults
|
||||
|
||||
if [ "$checkArchEos" = "yes" ] ; then
|
||||
echo2 "$upname $(ltr updt_update_check):"
|
||||
echo2 ":: $(ltr updt_searching) $upname $(ltr updt_for_updates)..."
|
||||
Checkupdates
|
||||
case "$?" in
|
||||
0)
|
||||
updates_found=yes
|
||||
ChecksForKeyrings
|
||||
if [ -n "${krpkg[0]}" ] && [ "$keyring_first" = "yes" ] ; then
|
||||
$EOS_ROOTER "pacman -Sy --needed --noconfirm ${krpkg[*]} && pacman -S ${args[*]}"
|
||||
else
|
||||
$EOS_ROOTER "pacman -Sy ${krpkg[*]} ${args[*]}"
|
||||
fi
|
||||
;;
|
||||
1) DIE "$(echo Checkupdates: "$(ltr updt_failure)" | sed 's|!$|!|')" ;; # sed: exclamation mark conversion
|
||||
2) echo2 " $(ltr updt_nothing_todo)" ;;
|
||||
esac
|
||||
[ "$checkAur" = "yes" ] && echo2 ""
|
||||
fi
|
||||
|
||||
if [ "$checkAur" = "yes" ] ; then
|
||||
echo2 "AUR $(ltr updt_update_check):"
|
||||
if which $aur_helper >& /dev/null ; then
|
||||
case "$aur_helper" in
|
||||
paru | */paru)
|
||||
$aur_helper -Sua
|
||||
if [ $? -ne 0 ] ; then
|
||||
updates_found=yes
|
||||
fi
|
||||
;;
|
||||
yay | */yay)
|
||||
$aur_helper -Sua
|
||||
updates_found=yes
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo2 ":: Warning: no AUR helper found."
|
||||
echo2 ":: Please check configuration file /etc/eos-script-lib-yad.conf,"
|
||||
echo2 ":: and check that the configured AUR helper is installed."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$updates_found" = "yes" ] ; then
|
||||
## shellcheck disable=SC2154
|
||||
if [ "$allow_sync" = "yes" ] || [ "$SyncAfterUpdate" = "yes" ] ; then # SyncAfterUpdate is an environment variable
|
||||
echo2 "==> Running 'sync' after update."
|
||||
sync
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Encoding=UTF-8
|
||||
Name=UpdateInTerminal
|
||||
Comment=Update system in terminal
|
||||
Comment[fi]=Päivitä järjestelmä uudessa pääteikkunassa
|
||||
Exec=bash -c "echo '==> yay'; yay; eos-sleep-counter 60"
|
||||
Terminal=true
|
||||
Icon=endeavouros-icon
|
||||
Hidden=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
X-KDE-autostart-after=panel
|
||||
Categories=System
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Convert curl return code to human friendly text.
|
||||
# See 'man curl' for more info.
|
||||
|
||||
DIE() {
|
||||
echo "Error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Generate() {
|
||||
local tmp=$(mktemp)
|
||||
local data=""
|
||||
|
||||
# Get exit codes and strings from the curl man page.
|
||||
data="$(MANWIDTH=$width man curl | sed -n '/^EXIT CODES$/,/^AUTHORS \/ CONTRIBUTORS$/'p | grep "^ [ ]*[0-9][0-9]* [ ]*")"
|
||||
data="$(echo "$data" | sed "s|\"|'|g")"
|
||||
data="$(echo "$data" | sed 's|^\([ ]*[0-9]*\)[ ]*\(.*\)|\1) echo "\2" ;;|')"
|
||||
|
||||
echo "==> Creating $converter" >&2
|
||||
cat <<EOF > "$converter"
|
||||
#!/bin/bash
|
||||
_generated_func_() {
|
||||
local curlRetCode="\$1"
|
||||
local msg
|
||||
case "\$curlRetCode" in
|
||||
$(echo "$data")
|
||||
0) echo "OK" ;;
|
||||
*) echo "[Error] The manual page of 'curl' does not recognize error code '\$curlRetCode'."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
_generated_func_ "\$1"
|
||||
EOF
|
||||
[ -r "$converter" ] || DIE "Creating '$converter' failed."
|
||||
chmod +x "$converter"
|
||||
}
|
||||
|
||||
usage_f() {
|
||||
local msg="$1"
|
||||
|
||||
cat <<EOF
|
||||
Convert the curl exit code to a descriptive string.
|
||||
|
||||
Usage: $progname { curl-exit-code | option }
|
||||
Options:
|
||||
-c, --create Generate up to date curl string list.
|
||||
-r, --remove Remove the current curl string list.
|
||||
-h, --help This help.
|
||||
|
||||
Example:
|
||||
$progname 6
|
||||
EOF
|
||||
|
||||
case "$msg" in
|
||||
"") exit 0 ;; # exit normally
|
||||
"stay") ;; # do not exit
|
||||
*) # exit with a message
|
||||
printf "\nError: %s\n" "$msg" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
CurlReturnCodeToString() {
|
||||
local progname=curl-exit-code-to-string
|
||||
local width=300 # man page error strings can be long, currently code 9 line needs over 200 characters ...
|
||||
|
||||
[ -n "$1" ] || usage_f "parameter missing"
|
||||
|
||||
local curlRetCode=""
|
||||
local cdir="$HOME/.config/$progname"
|
||||
local converter="$cdir/curl-code-to-string-converter"
|
||||
local timenow_sec=$(date +%s)
|
||||
local timefile_sec=0
|
||||
local generate_interval_seconds=$((3600*24*7)) # weekly automatic generation of the curl error code list
|
||||
|
||||
|
||||
mkdir -p "$cdir"
|
||||
|
||||
[ -r "$converter" ] && timefile_sec=$(stat -c %Y "$converter")
|
||||
|
||||
while [ -n "$1" ] ; do
|
||||
case "$1" in
|
||||
--create | -c) Generate ; return ;;
|
||||
--remove | -r) echo "==> Removing $converter" >&2 ; rm -f "$converter" ; return ;;
|
||||
--converter) echo "$converter" ; return 0 ;;
|
||||
--width) echo "$width" ; return 0 ;;
|
||||
--help | -h) usage_f ;;
|
||||
-*) DIE "unsupported option '$1'" ;;
|
||||
*) curlRetCode="$1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# ((timenow_sec += generate_interval_seconds)) # testing generation!
|
||||
|
||||
[ $timenow_sec -gt $((timefile_sec + generate_interval_seconds)) ] && Generate
|
||||
[ -x "$converter" ] || DIE "curl code to text converter '$converter' not found or not executable."
|
||||
|
||||
"$converter" "$curlRetCode"
|
||||
}
|
||||
|
||||
CurlReturnCodeToString "$@"
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Output one or more lines of information about
|
||||
# - wireless LAN
|
||||
# - ethernet controller
|
||||
# - display controller
|
||||
# - VGA compatible controller
|
||||
# - CPU
|
||||
# - is running in virtualbox vm
|
||||
# device.
|
||||
#
|
||||
# This command can be used e.g. with programs and scripts that
|
||||
# make decisions based on certain hardware,
|
||||
# or finding information about certain hardware.
|
||||
|
||||
Usage() {
|
||||
test -n "$1" && echo "Error: $1." >&2
|
||||
|
||||
cat <<EOF >&2
|
||||
Usage: $0 option
|
||||
where
|
||||
--wireless
|
||||
--wifi shows info about the wireless LAN device
|
||||
--ethernet shows info about the ethernet controller
|
||||
--display shows info about the display controller
|
||||
--vga shows info about the VGA compatible controller and 3D controller
|
||||
--graphics same as both --vga and --display
|
||||
--cpu shows the name of the CPU type
|
||||
--vm if running in VM, echoes the name of the VM (virtualbox, qemu, vmware)
|
||||
--virtualbox echoes "yes" is running in VirtualBox VM, otherwise "no"
|
||||
EOF
|
||||
}
|
||||
|
||||
PCI_info() {
|
||||
# Many search strings may be given - show all results.
|
||||
local result
|
||||
for str in "$@" ; do
|
||||
result="$(lspci | grep "$str" | sed 's|^.*'"$str"'||')"
|
||||
if [ -n "$result" ] ; then
|
||||
echo "$result"
|
||||
fi
|
||||
done
|
||||
}
|
||||
CPU_info() {
|
||||
# lscpu | grep "^Vendor ID:" | awk '{print $3}'
|
||||
grep -w "^vendor_id" /proc/cpuinfo | head -n 1 | awk '{print $3}'
|
||||
}
|
||||
|
||||
InVirtualBox() {
|
||||
if [ "$(InVm)" = "virtualbox" ] ; then
|
||||
echo yes
|
||||
else
|
||||
echo no
|
||||
fi
|
||||
#test -n "$(lspci | grep "VirtualBox Graphics Adapter")" && echo yes || echo no
|
||||
}
|
||||
|
||||
InVm() {
|
||||
local vmname="$(systemd-detect-virt --vm)"
|
||||
case "$vmname" in
|
||||
oracle)
|
||||
echo virtualbox ;;
|
||||
qemu | kvm | vmware)
|
||||
echo $vmname ;;
|
||||
esac
|
||||
return
|
||||
|
||||
# old implementation:
|
||||
case "$(lspci -vnn)" in
|
||||
*" QEMU "*) echo qemu ;;
|
||||
*VirtualBox*) echo virtualbox ;;
|
||||
*VMware*) echo vmware ;; # this should be the last here!
|
||||
esac
|
||||
}
|
||||
|
||||
EthernetShow() {
|
||||
local name="$1"
|
||||
local value="$2"
|
||||
printf "%-15s : %s\n" "$name" "$value"
|
||||
}
|
||||
Ethernet() {
|
||||
local devstring="Ethernet controller"
|
||||
local data=$(lspci -vnn | sed -n "/$devstring/,/^$/p")
|
||||
|
||||
local card=$( echo "$data" | grep -w "$devstring")
|
||||
local id=$( echo "$card" | sed 's|.*\[\([0-9a-f:]*\)\].*|\1|')
|
||||
local driver=$(echo "$data" | grep 'Kernel driver in use' | awk '{print $NF}')
|
||||
|
||||
EthernetShow "card id" "$id"
|
||||
EthernetShow "card info" "$card"
|
||||
EthernetShow "driver in use" "$driver"
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
test -n "$1" || { Usage "option missing" ; return 1 ; }
|
||||
|
||||
local arg
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
case "$arg" in
|
||||
--cpu) CPU_info ;;
|
||||
|
||||
--virtualbox) InVirtualBox ;;
|
||||
--vm) InVm ;;
|
||||
|
||||
--wireless | --wifi) PCI_info " Network controller: " ;;
|
||||
|
||||
--ethernet) Ethernet ;;
|
||||
|
||||
--display) PCI_info " Display controller: " ;;
|
||||
--vga) PCI_info " VGA compatible controller: " " 3D controller: " ;;
|
||||
--graphics) Main --vga ; Main --display ;;
|
||||
|
||||
*) Usage "unsupported option '$arg'"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
#FindAppIconKDE() {
|
||||
# local app="$1"
|
||||
# local sz
|
||||
# local path
|
||||
#
|
||||
# for sz in "48" "48x48" ; do
|
||||
# path="$(/usr/bin/find /usr/share/icons -name "$app".\* | /usr/bin/grep /${sz}/ | /usr/bin/head -n 1)"
|
||||
# test -n "$path" && {
|
||||
# echo "$path"
|
||||
# return
|
||||
# }
|
||||
# done
|
||||
# #echo "Sorry, icon path not found for app '$app'." >&2
|
||||
#}
|
||||
|
||||
|
||||
FindDesktopIcon() {
|
||||
local app="$1"
|
||||
local path
|
||||
local dir=/usr/share/applications
|
||||
|
||||
if [ -r $dir/"$app".desktop ] ; then
|
||||
path="$(grep "^Icon=" $dir/"$app".desktop | head -n 1 | cut -d '=' -f 2)"
|
||||
if [ -n "$path" ] ; then
|
||||
echo "$path"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
FindAppIcon() {
|
||||
source /etc/eos-script-lib-yad.conf || return 1
|
||||
|
||||
local progname="$(/usr/bin/basename "$0")"
|
||||
local app="$1"
|
||||
local sz
|
||||
local path paths
|
||||
local set
|
||||
local icon_sets=()
|
||||
|
||||
for set in "${EOS_ICON_SETS_PREFERENCE[@]}" ; do
|
||||
icon_sets+=("${set##*/}")
|
||||
done
|
||||
|
||||
FindDesktopIcon "$app" && return
|
||||
|
||||
for set in "${icon_sets[@]}" ; do
|
||||
paths="$(find "/usr/share/icons/$set" -name "$app".\*)"
|
||||
path="$(echo "$paths" | grep "/scalable/" | head -n1)"
|
||||
[ -z "$path" ] && path="$(echo "$paths" | sort -r | head -n1)"
|
||||
[ -z "$path" ] && path=$(yad-tools -i "$app" 2>/dev/null)
|
||||
if [ -n "$path" ] ; then
|
||||
echo "$path"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
local log="/tmp/${progname}-issues-$EUID.log"
|
||||
echo "$progname: sorry, icon path not found for app '$app'." >> "$log"
|
||||
}
|
||||
|
||||
FindAppIcon "$@"
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Checks that an internet connection exists.
|
||||
# Return value is 0 on success, or another number on failure.
|
||||
#
|
||||
# Program 'curl-exit-code-to-string' can convert the error code to a human readable message (see below).
|
||||
#
|
||||
# Example usage:
|
||||
# eos-connection-checker && echo connection is ON
|
||||
# eos-connection-checker || echo connection is OFF
|
||||
# eos-connection-checker || curl-exit-code-to-string $?
|
||||
|
||||
GetFastestMirror() {
|
||||
# This assumes eos-rankmirrors has been executed on the current list.
|
||||
# If not, then this does essentially nothing.
|
||||
grep -A10 "^# mirror [ ]*update-level" /etc/pacman.d/endeavouros-mirrorlist | grep "^# https://" | sort -k4 | head -n1 | awk '{print $2}' | sed 's|\([^$]*\)/\$.*|\1|'
|
||||
}
|
||||
|
||||
Main() {
|
||||
# These addresses will be used for checking the availability of internet access.
|
||||
# If you have issues with the addresses, please report this at this site:
|
||||
# https://forum.endeavouros.com
|
||||
#
|
||||
local URLs=(
|
||||
# This should work globally.
|
||||
#https://geoip.kde.org/v1/calamares # this doesn't seem to work anymore?
|
||||
|
||||
# EndeavourOS mirrors (fastest first).
|
||||
|
||||
$(GetFastestMirror)
|
||||
$(grep ^Server /etc/pacman.d/endeavouros-mirrorlist | sed 's|^Server[ ]*=[ ]*\([^$]*\)/\$.*|\1|')
|
||||
)
|
||||
local URL
|
||||
local retval
|
||||
|
||||
for URL in "${URLs[@]}" ; do
|
||||
/usr/bin/curl --silent --fail --connect-timeout 8 "$URL" >/dev/null
|
||||
retval=$?
|
||||
[ $retval -eq 0 ] && break
|
||||
done
|
||||
return $retval
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+231
@@ -0,0 +1,231 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copy additional wallpapers from Github's EOS site.
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || exit 1
|
||||
|
||||
DIE() { echo "$progname: error: $1" >&2 ; exit 1 ; }
|
||||
WARN() { echo "$progname: warning: $1" >&2 ; }
|
||||
pushd() { command pushd "$@" >/dev/null ; }
|
||||
popd() { command popd "$@" >/dev/null ; }
|
||||
echo2() { echo "$@" >&2 ; }
|
||||
echo2i() { echo "$@" | sed 's|^| |' >&2 ; }
|
||||
|
||||
# TestingTimeStamp() { [ "$TESTING" = "yes" ] && date "+%H:%M:%S" ; }
|
||||
|
||||
GetWallsCurl() {
|
||||
local repofolders
|
||||
local subfolder
|
||||
local subfolderfiles
|
||||
local directurl=https://raw.githubusercontent.com/EndeavourOS-Community-Editions/Community-wallpapers/main
|
||||
local file files
|
||||
local timeout=10 # for fetching info page
|
||||
local timeoutfiles=30 # for fetching actual wallpaper files
|
||||
local gotwalls=no
|
||||
|
||||
readarray -t repofolders <<< $(curl -Lsm $timeout "$repopage" | grep /tree/main/ | sed -e 's|.*.*/main/||' -e 's|".*||')
|
||||
if [ -n "$repofolders" ] ; then
|
||||
echo2 "====> The following wallpaper folders are available:"
|
||||
for subfolder in "${repofolders[@]}" ; do
|
||||
echo2i "$subfolder"
|
||||
done
|
||||
echo2 ""
|
||||
|
||||
mkdir -p $mainfolder
|
||||
pushd $mainfolder
|
||||
|
||||
for subfolder in "${repofolders[@]}" ; do
|
||||
read -p "====> Fetch wallpapers from $subfolder (Y/n)? " >&2
|
||||
case "$REPLY" in
|
||||
""|[Yy]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
|
||||
echo2 "====> Fetching ..."
|
||||
readarray -t subfolderfiles <<< $(curl -Lsm $timeout "$repopage/tree/main/$subfolder" | grep /blob/main/ | sed -e "s|.*/main/$subfolder/||" -e 's|".*||')
|
||||
if [ -z "$subfolderfiles" ] ; then
|
||||
WARN "$FUNCNAME: did not find files in '$repopage/$subfolder'."
|
||||
continue
|
||||
fi
|
||||
|
||||
mkdir -p "$subfolder"
|
||||
pushd "$subfolder"
|
||||
|
||||
files=()
|
||||
for file in "${subfolderfiles[@]}" ; do
|
||||
files+=("$directurl/$subfolder/$file")
|
||||
done
|
||||
if (curl -Lsm $timeoutfiles --fail-early --remote-name-all "${files[@]}") ; then
|
||||
gotwalls=yes
|
||||
else
|
||||
WARN "$FUNCNAME: fetching files from '$repopage/$subfolder' failed."
|
||||
retval=1
|
||||
fi
|
||||
|
||||
popd
|
||||
done
|
||||
|
||||
popd
|
||||
else
|
||||
WARN "$FUNCNAME: fetching subfolder names from '$repopage' failed."
|
||||
retval=1
|
||||
fi
|
||||
|
||||
[ "$gotwalls" = "no" ] && retval=1
|
||||
}
|
||||
|
||||
gh2gl() {
|
||||
local url="$1"
|
||||
|
||||
case "$EOS_FILESERVER_SITE" in
|
||||
github)
|
||||
echo "$url"
|
||||
;;
|
||||
gitlab | *)
|
||||
case "$url" in
|
||||
"https://github.com/EndeavourOS-Community-Editions/Community-wallpapers")
|
||||
echo "https://gitlab.com/endeavouros-filemirror/Community-wallpapers"
|
||||
;;
|
||||
*)
|
||||
DIE "sorry, this program can't use 'curl' with gitlab. Use 'git' instead."
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
GetWalls() {
|
||||
local retval=0
|
||||
|
||||
case "$implementation" in
|
||||
curl) GetWallsCurl ;;
|
||||
git) git clone "$url" || retval=1 ;;
|
||||
esac
|
||||
return $retval
|
||||
}
|
||||
|
||||
FetchWallpapers() {
|
||||
# Copy new wallpapers into their place.
|
||||
# Remove old wallpapers first.
|
||||
|
||||
local mainfolder=Community-wallpapers
|
||||
local repopage=$(gh2gl https://github.com/EndeavourOS-Community-Editions/$mainfolder)
|
||||
local url=$repopage.git
|
||||
local urlsubdirs=(
|
||||
eos_wallpapers_classic
|
||||
eos_wallpapers_community
|
||||
)
|
||||
local targetroot=/usr/share/endeavouros/backgrounds
|
||||
|
||||
local subdir
|
||||
local cmd # real commands here
|
||||
local cmd2 # displayed commands here
|
||||
|
||||
GetWalls || return 1
|
||||
|
||||
pushd "$mainfolder"
|
||||
|
||||
# Collect all required commands into $cmd:
|
||||
|
||||
cmd="mkdir -p $targetroot" # collect all needed commands into $cmd
|
||||
|
||||
for subdir in "${urlsubdirs[@]}" ; do
|
||||
[ -d "$subdir" ] || continue # skip if not folder
|
||||
if [ -d "$targetroot/$subdir" ] ; then
|
||||
echo2 "====> Note: will remove existing $targetroot/$subdir"
|
||||
cmd+=" ; rm -rf '$targetroot/$subdir'" # will remove old wallpapers
|
||||
fi
|
||||
cmd+=" ; cp -r '$PWD/$subdir' $targetroot/" # will copy new wallpapers in place
|
||||
done
|
||||
cmd2=$(echo "$cmd" | sed 's| ; |\n|g') # reformat commands suitable for displaying
|
||||
|
||||
|
||||
# Now do the actual wallpaper changes:
|
||||
|
||||
echo2 ""
|
||||
echo2 "Running the following commands:"
|
||||
echo2 "$cmd2"
|
||||
echo2 ""
|
||||
$EOS_ROOTER "$cmd"
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
Options() {
|
||||
local arg
|
||||
local default="[default]"
|
||||
|
||||
for arg in "$@" ; do
|
||||
case "$arg" in
|
||||
--curl) implementation=curl ;;
|
||||
--git) implementation=git ;;
|
||||
--no-choose) make_choose=no ;;
|
||||
--help | -h)
|
||||
cat <<EOF
|
||||
Usage: $progname [options]
|
||||
Options:
|
||||
--curl Download using curl (should use less bandwidth). $( [ $implementation_default = curl ] && echo $default )
|
||||
--git Download using git. $( [ $implementation_default = git ] && echo $default )
|
||||
--no-choose Do not make user to choose wallpaper right after downloading.
|
||||
--help | -h This help.
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
*) DIE "unsupported parameter '$arg'" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local progname="$(basename "$0")"
|
||||
local tmpdirbase="$HOME/.cache/$progname"
|
||||
local workdir
|
||||
local implementation_default="$EOS_WALLPAPER_FETCHER"
|
||||
local implementation=$implementation_default
|
||||
local make_choose=yes
|
||||
local retval=0
|
||||
local oldies
|
||||
|
||||
[ -n "$implementation_default" ] || implementation_default=git
|
||||
|
||||
# options will override the default values
|
||||
Options "$@"
|
||||
|
||||
if [ "$EOS_FILESERVER_SITE" != "github" ] ; then
|
||||
if [ "$implementation" != "git" ] ; then
|
||||
echo2 "$progname: info: using 'git' instead of 'curl'."
|
||||
implementation=git
|
||||
fi
|
||||
fi
|
||||
|
||||
workdir=$(mktemp -d "$tmpdirbase.XXXXX")
|
||||
|
||||
pushd "$workdir"
|
||||
FetchWallpapers || retval=1
|
||||
popd
|
||||
|
||||
rm -rf "$workdir" # cleanup
|
||||
|
||||
oldies="$(/usr/bin/ls -1d "$tmpdirbase".* 2>/dev/null)"
|
||||
if [ -n "$oldies" ] ; then
|
||||
echo2 ""
|
||||
echo2 "====> Warning: the following old temporary folders can be deleted."
|
||||
echo2i "$oldies"
|
||||
read -p "====> Delete now (Y/n)? " >&2
|
||||
case "$REPLY" in
|
||||
""|[Yy]*) rm -rf $oldies ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Allow user to change the wallpaper:
|
||||
|
||||
if [ "$make_choose" = "yes" ] ; then
|
||||
if [ $retval -eq 0 ] ; then
|
||||
echo2 "You can choose your new wallpaper now:"
|
||||
/usr/bin/eos-wallpaper-set &
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Convert some github URLs to corresponding gitlab mirror URLs.
|
||||
|
||||
DIE() {
|
||||
local progname="$(basename "$0")"
|
||||
echo "==> $progname: error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Github2Gitlab_new() {
|
||||
# Get value of variable EOS_FILESERVER_SITE.
|
||||
source /etc/eos-script-lib-yad.conf || DIE "init failed."
|
||||
|
||||
local github_url="$1" # This URL may be converted to gitlab mirror.
|
||||
local keep_master=no # PKGBUILDS repofolder defaults to branch name 'master'.
|
||||
|
||||
# Manage the only option, --keep-master.
|
||||
# Note: option should be removed, used only in eos-rankmirrors (?)
|
||||
case "$1" in
|
||||
--keep-master)
|
||||
github_url="$2"
|
||||
keep_master=yes
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check parameter validity.
|
||||
[ -n "$github_url" ] || DIE "no URL!"
|
||||
[[ "$github_url" =~ github ]] || DIE "'$github_url' is not a github URL"
|
||||
|
||||
# See which conversions are needed.
|
||||
case "$EOS_FILESERVER_SITE" in
|
||||
github)
|
||||
echo "$github_url" # If github is selected, URL is already OK.
|
||||
;;
|
||||
gitlab)
|
||||
# Some repos still use the 'master' branch.
|
||||
[[ "$github_url" =~ /endeavouros-team/PKGBUILDS/ ]] && keep_master=yes
|
||||
|
||||
# Start constructing needed conversions.
|
||||
local convert_to_gitlab=(
|
||||
sed
|
||||
-e 's|/endeavouros-team/|/endeavouros-filemirror/|'
|
||||
-e 's|/endeavouros-team$|/endeavouros-filemirror|'
|
||||
)
|
||||
if [[ "$github_url" =~ '//raw.githubusercontent.com/' ]] ; then
|
||||
# a few more conversions needed
|
||||
convert_to_gitlab+=(
|
||||
-e 's|//raw\.githubusercontent\.com/|//gitlab.com/|'
|
||||
-e 's|/main/|/raw/main/|'
|
||||
-e 's|/calamares/calamares/|/raw/calamares/calamares/|' # ???
|
||||
-e 's|/blob/|/raw/|' # ???
|
||||
-e 's|/tree/|/blob/|' # ???
|
||||
)
|
||||
case "$keep_master" in
|
||||
yes) convert_to_gitlab+=(-e 's|/master/|/raw/master/|') ;;
|
||||
no) convert_to_gitlab+=(-e 's|/master/|/raw/main/|') ;;
|
||||
esac
|
||||
elif [[ "$github_url" =~ '//github.com/' ]] ; then
|
||||
# not much more to convert
|
||||
convert_to_gitlab+=(
|
||||
-e 's|//github\.com/|//gitlab.com/|'
|
||||
)
|
||||
fi
|
||||
|
||||
# Now make the conversion.
|
||||
echo "$github_url" | "${convert_to_gitlab[@]}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Github2Gitlab() { # old implementation
|
||||
local url
|
||||
local keep_master=no
|
||||
|
||||
case "$1" in
|
||||
--keep-master) url="$2" ; keep_master=yes ;;
|
||||
*) url="$1" ;;
|
||||
esac
|
||||
|
||||
source /etc/eos-script-lib-yad.conf
|
||||
|
||||
case "$EOS_FILESERVER_SITE" in
|
||||
github)
|
||||
echo "$url"
|
||||
;;
|
||||
gitlab | *)
|
||||
local sed=(sed)
|
||||
if [ -n "$(echo "$url" | grep "/raw\.githubusercontent\.com/")" ] ; then
|
||||
sed+=(-e 's|/raw\.githubusercontent\.com/|/gitlab.com/|')
|
||||
sed+=(-e 's|/main/|/-/raw/main/|' )
|
||||
if [ "$keep_master" = "yes" ] ; then
|
||||
sed+=(-e 's|/master/|/-/raw/master/|')
|
||||
else
|
||||
sed+=(-e 's|/master/|/-/raw/main/|')
|
||||
fi
|
||||
sed+=(-e 's|/endeavouros-team/calamares/|/endeavouros-team/calamares/-/raw/|' )
|
||||
sed+=(-e 's|/install-scripts-next/|/install-scripts-next/-/raw/|')
|
||||
else
|
||||
sed+=(-e 's|/github\.com/|/gitlab.com/|')
|
||||
fi
|
||||
sed+=(
|
||||
-e 's|/endeavouros-team/|/endeavouros-filemirror/|'
|
||||
-e 's|/tree/master/|/-/blob/master/|'
|
||||
-e 's|/blob/master/|/-/blob/master/|'
|
||||
-e 's|/eos-bash-shared$|/eos-apps-info|' # ???
|
||||
)
|
||||
echo "$url" | "${sed[@]}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Github2Gitlab "$@"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
Main() {
|
||||
if (eos-connection-checker) ; then
|
||||
local country=$(show-location-info country | tr '[:upper:]' '[:lower:]')
|
||||
case "$country" in
|
||||
de|fi|se)
|
||||
echo "Setting keyboard layout to: $country" > /tmp/eos-kbd-set.log
|
||||
setxkbmap $country
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
#!/bin/bash
|
||||
|
||||
# On Nvidia GPU machines, kernel and nvidia driver must update together:
|
||||
# - if linux-lts is updated, nvidia-lts should be updated too
|
||||
# - if linux is updated, nvidia should be updated too
|
||||
# Note that if an nvidia*dkms driver is installed, we have nothing to check.
|
||||
#
|
||||
# This app checks the above and informs the calling app with exit code:
|
||||
# 0=success
|
||||
# 1=failure
|
||||
# On failure also error messages to stderr will be displayed.
|
||||
|
||||
DIE() {
|
||||
echo "$progname: error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
Exit() {
|
||||
if [ $1 -eq 0 ] && [ "$test_mode" = "yes" ] && [ "$need_check" = "yes" ] ; then
|
||||
exit 2
|
||||
else
|
||||
exit $1
|
||||
fi
|
||||
}
|
||||
|
||||
Main() {
|
||||
local opt="$1"
|
||||
local test_mode=no
|
||||
local need_check=no
|
||||
|
||||
PATH=/usr/bin:$PATH
|
||||
|
||||
local -r progname=$(basename "$0")
|
||||
|
||||
case "$opt" in
|
||||
--needed) test_mode=yes ; shift ;;
|
||||
-*) DIE "unsupported option '$1'." ;;
|
||||
esac
|
||||
|
||||
# Quick check is Nvidia modules are in use.
|
||||
lsmod | grep nvidia >/dev/null || Exit 0
|
||||
|
||||
# Some NVIDIA module(s) are in use. Check installed packages.
|
||||
|
||||
local -r inst=$(pacman -Qsq | grep -P '^nvidia|^linux$|^linux-lts$')
|
||||
|
||||
# If any of these nvidia dkms versions are installed, we have nothing to do.
|
||||
[ -n "$(echo "$inst" | grep ^nvidia-dkms$)" ] && Exit 0
|
||||
[ -n "$(echo "$inst" | grep ^nvidia-470xx-dkms$)" ] && Exit 0
|
||||
[ -n "$(echo "$inst" | grep ^nvidia-390xx-dkms$)" ] && Exit 0
|
||||
|
||||
while true ; do
|
||||
# Check if "nvidia & linux" or "nvidia-lts & linux-lts" are installed.
|
||||
if [ -n "$(echo "$inst" | grep ^nvidia$)" ] && [ -n "$(echo "$inst" | grep ^linux$)" ] ; then
|
||||
need_check=yes
|
||||
break
|
||||
fi
|
||||
if [ -n "$(echo "$inst" | grep ^nvidia-lts$)" ] && [ -n "$(echo "$inst" | grep ^linux-lts$)" ] ; then
|
||||
need_check=yes
|
||||
break
|
||||
fi
|
||||
Exit 0 # no checks needed
|
||||
done
|
||||
[ "$test_mode" = "yes" ] && Exit 0 # don't do actual checks in test mode
|
||||
|
||||
# Currently installed:
|
||||
# - linux and nvidia
|
||||
# and/or
|
||||
# - linux-lts and nvidia-lts
|
||||
# No dkms version is installed.
|
||||
|
||||
# Now check that if linux/linux-lts is in the updates list, corresponding nvidia/nvidia-lts must be there too.
|
||||
|
||||
local linux_lts=no
|
||||
local linux=no
|
||||
local nvidia_lts=no
|
||||
local nvidia=no
|
||||
local msgs=() msg
|
||||
local pkgs pkg
|
||||
|
||||
# Find updates if they are not as parameters.
|
||||
if [ -z "$1" ] ; then
|
||||
readarray -t pkgs <<< $(checkupdates | awk '{print $1}')
|
||||
else
|
||||
pkgs=("$@")
|
||||
fi
|
||||
|
||||
# Check if kernel(s) and nvidia driver(s) are in the updates list.
|
||||
for pkg in "${pkgs[@]}" ; do
|
||||
case "$pkg" in
|
||||
linux) linux=yes ;;
|
||||
linux-lts) linux_lts=yes ;;
|
||||
nvidia) nvidia=yes ;;
|
||||
nvidia-lts) nvidia_lts=yes ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Notify if kernel will be updated but corresponding nvidia driver not.
|
||||
|
||||
[ "$linux_lts $nvidia_lts" = "yes no" ] && msgs+=("'linux-lts' would be upgraded but 'nvidia-lts' not.")
|
||||
[ "$linux_lts $nvidia_lts" = "no yes" ] && msgs+=("'nvidia-lts' would be upgraded but 'linux-lts' not.")
|
||||
[ "$linux $nvidia" = "yes no" ] && msgs+=("'linux' would be upgraded but 'nvidia' not.")
|
||||
[ "$linux $nvidia" = "no yes" ] && msgs+=("'nvidia' would be upgraded but 'linux' not.")
|
||||
|
||||
if [ ${#msgs[@]} -gt 0 ] ; then
|
||||
for msg in "${msgs[@]}" ; do
|
||||
echo "==> $progname: error: $msg" >&2
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Pacdiff for EndeavourOS.
|
||||
|
||||
IsInstalled() { pacman -Qq "$1" >& /dev/null ; }
|
||||
HasLibs() { IsInstalled webkit2gtk ; }
|
||||
|
||||
SafetyWarning() {
|
||||
if [ "$EOS_PACDIFF_WARNING" = "yes" ] ; then
|
||||
local txt=""
|
||||
txt+="NOTE: <b>eos-pacdiff</b> is a powerful tool, so use it carefully!\n\n"
|
||||
txt+="For example, please do <i>not</i> modify files like:\n"
|
||||
txt+="<tt> /etc/passwd</tt>\n"
|
||||
txt+="<tt> /etc/group</tt>\n"
|
||||
txt+="<tt> /etc/shadow</tt>\n"
|
||||
txt+="and related files unless you know <i>exactly</i> what you are doing.\n\n"
|
||||
txt+="You can remove this warning popup by changing the value of\n"
|
||||
txt+="variable <tt>EOS_PACDIFF_WARNING</tt> in file <tt>/etc/eos-script-lib-yad.conf</tt>.\n"
|
||||
txt+="Note that you may need to merge the changes from\nfile /etc/eos-script-lib-yad.conf.pacnew first!\n"
|
||||
|
||||
if HasLibs ; then
|
||||
eos_yad --form --image=dialog-warning --title="Warning" --text="$txt" --button=yad-quit #--width=400 --height=300
|
||||
else
|
||||
txt="$(echo "$txt" | sed -e 's|<[/bit]*>||g' -e 's|\\n|\n|g')"
|
||||
printf "%s\n\n" "$txt" >&2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
HasPacdiffs() { test -n "$(echo q | DIFFPROG=diff /usr/bin/pacdiff)" ; }
|
||||
DoesSudo() { groups | grep -Pw 'root|wheel' >/dev/null ; }
|
||||
|
||||
PacdiffCmd() {
|
||||
local differ="$1"
|
||||
local cmd="" prompt=""
|
||||
local msg=""
|
||||
|
||||
if HasPacdiffs ; then
|
||||
case "$differ" in # some differs may need options
|
||||
vim) differ+=" -d" ;;
|
||||
esac
|
||||
|
||||
msg="Starting pacdiff & $differ as root ..."
|
||||
|
||||
prompt="echo '$msg'"
|
||||
if DoesSudo ; then
|
||||
cmd="/usr/bin/sudo DIFFPROG='/usr/bin/$differ' /usr/bin/pacdiff 2>/dev/null"
|
||||
else
|
||||
cmd="DIFFPROG='/usr/bin/$differ' /usr/bin/su-c_wrapper -p /usr/bin/pacdiff 2>/dev/null"
|
||||
fi
|
||||
|
||||
if [ $start_new_terminal = yes ] ; then
|
||||
RunInTerminal "$prompt ; $cmd"
|
||||
else
|
||||
bash -c "$prompt ; $cmd"
|
||||
fi
|
||||
return $diffs_yes
|
||||
else
|
||||
msg="eos-pacdiff: nothing to do."
|
||||
if [ $start_new_terminal = yes ] ; then
|
||||
if HasLibs ; then
|
||||
eos_yad_nothing_todo "<tt>$msg</tt>" 5
|
||||
else
|
||||
echo "$indent$msg" >&2
|
||||
fi
|
||||
return $diffs_no_nt
|
||||
else
|
||||
echo "$indent$msg" >&2
|
||||
return $diffs_no
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
# exit codes
|
||||
local diffs_yes=0
|
||||
local diffs_error=1
|
||||
local diffs_no=2
|
||||
local diffs_no_nt=3
|
||||
|
||||
local start_new_terminal=no
|
||||
local indent=""
|
||||
case "$1" in
|
||||
--indent=*) indent="${1#*=}" ;;
|
||||
--nt) start_new_terminal=yes ;;
|
||||
esac
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || return $diffs_error
|
||||
export -f eos_yad
|
||||
export -f eos_yad_nothing_todo
|
||||
|
||||
SafetyWarning
|
||||
|
||||
# see /etc/eos-script-lib-yad.conf about EOS_WELCOME_PACDIFFERS
|
||||
|
||||
for differ in "${EOS_WELCOME_PACDIFFERS[@]}" ; do
|
||||
if [ -x /usr/bin/$differ ] ; then
|
||||
PacdiffCmd "$differ"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIE() {
|
||||
echo "$progname: error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
SetBrowser() { # should use eos_select_browser() instead...
|
||||
local browser
|
||||
|
||||
for browser in $_WELCOME_BROWSER xdg-open exo-open firefox chromium vivaldi-stable opera ; do
|
||||
if [ -x /usr/bin/$browser ] ; then
|
||||
Browser=/usr/bin/$browser
|
||||
return
|
||||
fi
|
||||
done
|
||||
DIE "$FUNCNAME: cannot find a web browser"
|
||||
}
|
||||
|
||||
EosPackages() {
|
||||
wget -q -O- https://github.com/endeavouros-team/PKGBUILDS | grep ' href="/endeavouros-team/PKGBUILDS/tree/master/' | sed 's|.*/tree/master/\([^"]*\).*|\1|' | \
|
||||
grep -P -v 'z_archived|ckbcomp'
|
||||
}
|
||||
|
||||
HasPkgbuild() {
|
||||
local pkgs="$(EosPackages)"
|
||||
local pkg
|
||||
for pkg in $pkgs ; do
|
||||
if [ "$pkgname" = "$pkg" ] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
case "$pkgname" in
|
||||
mkinitcpio-openswap)
|
||||
pkgname=openswap ; return 0 ;;
|
||||
grub-theme2-endeavouros)
|
||||
pkgname=grub-theme-endeavouros ; return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local pkgname="$1"
|
||||
local progname="$(basename "$0")"
|
||||
local urlbase=https://github.com/endeavouros-team/PKGBUILDS/commits/master
|
||||
local Browser=""
|
||||
|
||||
SetBrowser
|
||||
urlbase=$(eos-github2gitlab "$urlbase")
|
||||
|
||||
if (HasPkgbuild) ; then
|
||||
[ -n "$Browser" ] && $Browser "$urlbase/$pkgname" >& /dev/null
|
||||
#else
|
||||
# eos-pkginfo "$pkgname"
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+171
@@ -0,0 +1,171 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIE() {
|
||||
echo "$PROGNAME: error: $1" >&2
|
||||
Usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
Helper() {
|
||||
for HELPER in paru yay ; do
|
||||
if [ -x /usr/bin/$HELPER ] ; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
DIE "AUR helper not found!"
|
||||
}
|
||||
|
||||
FindUrl() {
|
||||
# If $PKGNAME is not a package, then assume it is a file of an installed package and find the package name.
|
||||
|
||||
if (! /usr/bin/$HELPER -Q "$PKGNAME" >& /dev/null) ; then
|
||||
if (! /usr/bin/$HELPER -Si "$PKGNAME" >& /dev/null) ; then
|
||||
local item fail=no
|
||||
case "${PKGNAME::1}" in
|
||||
"/") item="$PKGNAME" ;; # file name
|
||||
*) item="/usr/bin/$PKGNAME" ;; # program name
|
||||
esac
|
||||
if [ -r "$item" ] ; then
|
||||
PKGNAME="$(LANG=C /usr/bin/$HELPER -Qo "$item" 2>/dev/null | awk '{print $(NF-1)}')"
|
||||
[ -z "$PKGNAME" ] && DIE "given name '$PKGNAME' does not refer to a package or an installed file."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
PKGINFO="$(LANG=C $HELPER -Qi "$PKGNAME" 2>/dev/null)"
|
||||
if [ -z "$PKGINFO" ] ; then
|
||||
PKGINFO="$(LANG=C $HELPER -Si "$PKGNAME" 2>/dev/null)"
|
||||
fi
|
||||
[ -n "$PKGINFO" ] || DIE "package '$PKGNAME' not found"
|
||||
}
|
||||
|
||||
IsEndeavourOSpkg() {
|
||||
local pkg="$1"
|
||||
local eos_pkg
|
||||
local eos_pkgs
|
||||
|
||||
readarray -t eos_pkgs <<< $(/usr/bin/pacman -Slq endeavouros)
|
||||
|
||||
for eos_pkg in "${eos_pkgs[@]}" ; do
|
||||
if [ "$pkg" = "$eos_pkg" ] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
Github2Gitlab_local() {
|
||||
echo "$url"
|
||||
return
|
||||
|
||||
eos-github2gitlab "$@"
|
||||
return
|
||||
|
||||
local url="$1"
|
||||
|
||||
case "$EOS_FILESERVER_SITE" in
|
||||
gitlab)
|
||||
echo "$url" | sed -e 's|/github\.com/|/gitlab.com/|' \
|
||||
-e 's|/endeavouros-team/|/endeavouros-filemirror/|' \
|
||||
-e 's|/tree/master/|/-/blob/master/|' \
|
||||
-e 's|/eos-bash-shared$|/eos-apps-info|'
|
||||
;;
|
||||
github | *)
|
||||
echo "$url" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
FixUrl() {
|
||||
# PKGNAME and PKGNAME_ARG may be different. Then PKGNAME_ARG is a program name,
|
||||
# and it may have a special man page.
|
||||
|
||||
# if pkg has several apps, or pkgname is also a special app:
|
||||
# Here we handle EndeavourOS packages only.
|
||||
|
||||
local man=""
|
||||
local man_add
|
||||
|
||||
case "$PKGNAME_ARG" in
|
||||
eos-welcome | $PKGNAME)
|
||||
man_add="/man/$PKGNAME/$PKGNAME.md"
|
||||
;;
|
||||
*) man_add="/man/$PKGNAME_ARG/$PKGNAME_ARG.md"
|
||||
;;
|
||||
esac
|
||||
man="$(Github2Gitlab_local "$url")"
|
||||
man+="$man_add"
|
||||
if (wget -q --timeout=5 -O /dev/null "$man") ; then
|
||||
url+="$man_add"
|
||||
#url="$man"
|
||||
fi
|
||||
}
|
||||
|
||||
OpenUrl() {
|
||||
local url="$(echo "$PKGINFO" | /usr/bin/grep ^URL | /usr/bin/head -n1 | /usr/bin/awk '{print $NF}')"
|
||||
case "$url" in
|
||||
https://*) ;;
|
||||
http://*)
|
||||
read -p "Change $url to https based (Y/n)? " >&2
|
||||
case "$REPLY" in
|
||||
""|[yY]*) url="${url/http:/https:}" ;;
|
||||
esac
|
||||
;;
|
||||
"") DIE "URL for package '$PKGNAME' not found" ;;
|
||||
*) DIE "unsupported URL '$url'" ;;
|
||||
esac
|
||||
|
||||
if (IsEndeavourOSpkg "$PKGNAME_ARG") ; then
|
||||
eos-apps-info-helper "$PKGNAME"
|
||||
else
|
||||
FixUrl
|
||||
#echo "$BROWSER" "$url" >&2
|
||||
$BROWSER "$url" >& /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Options() {
|
||||
PKGNAME=""
|
||||
PKGNAME_ARG=""
|
||||
|
||||
local arg
|
||||
|
||||
for arg in "$@" ; do
|
||||
case "$arg" in
|
||||
--browser=*) BROWSER="${arg#*=}" ;;
|
||||
-*) DIE "option $arg is not supported." ;;
|
||||
*) PKGNAME="$arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$PKGNAME" ] || DIE "give package-name"
|
||||
|
||||
PKGNAME_ARG="$PKGNAME"
|
||||
}
|
||||
|
||||
Usage() {
|
||||
cat <<EOF >&2
|
||||
Usage: $PROGNAME <name>
|
||||
<name> A package name, program name, or a file path included in a package.
|
||||
Given program name or file path must exist in the current system.
|
||||
The package can be from EndeavourOS, Arch, or AUR.
|
||||
EOF
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
source /etc/eos-script-lib-yad.conf || return 1
|
||||
|
||||
local PROGNAME="$(/usr/bin/basename "$0")"
|
||||
local PKGNAME
|
||||
local PKGNAME_ARG
|
||||
local HELPER
|
||||
local PKGINFO
|
||||
local BROWSER=/usr/bin/xdg-open
|
||||
|
||||
Helper
|
||||
Options "$@"
|
||||
FindUrl
|
||||
OpenUrl
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
@@ -0,0 +1,102 @@
|
||||
# bash completion for eos-pkginfo -*- shell-script -*-
|
||||
|
||||
_eos-pkginfo_complete() {
|
||||
COMPREPLY=( $(compgen -W "$1" -- "$cur") )
|
||||
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||
}
|
||||
|
||||
_eos-pkginfo_aur()
|
||||
{
|
||||
local cur prev #words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
local weekofyear=$(/usr/bin/date +%V)
|
||||
local datafilebase="$HOME/.config/eos-pkginfo-aur.txt"
|
||||
local datafile="$datafilebase.$weekofyear"
|
||||
|
||||
if [ ! -r "$datafile" ] ; then
|
||||
# Update database file.
|
||||
# Note that a systemd service (--user) can update too.
|
||||
|
||||
# AUR helpers are very slow for this!
|
||||
local helper=/usr/bin/paru
|
||||
[ -x $helper ] || helper=/usr/bin/yay
|
||||
|
||||
rm -f "$datafilebase".*
|
||||
$helper -Slq aur > "$datafile"
|
||||
fi
|
||||
_eos-pkginfo_complete "$(cat "$datafile")"
|
||||
}
|
||||
|
||||
_eos-pkginfo_()
|
||||
{
|
||||
local cur prev #words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
local pkgs=( # pacman -Slq endeavouros # excluding some
|
||||
akm
|
||||
arc-gtk-theme-eos
|
||||
endeavouros-keyring
|
||||
endeavouros-mirrorlist
|
||||
endeavouros-theming
|
||||
endeavouros-xfce4-terminal-colors
|
||||
eos-bash-shared
|
||||
eos-hooks
|
||||
eos-log-tool
|
||||
eos-translations
|
||||
eos-update-notifier
|
||||
grub-tools
|
||||
grub2-theme-endeavouros
|
||||
nvidia-installer-db
|
||||
nvidia-installer-dkms
|
||||
pahis
|
||||
reflector-bash-completion
|
||||
reflector-simple
|
||||
welcome
|
||||
)
|
||||
local apps=( # pacman -Flq "${pkgs[@]}" | grep ^usr/bin/. | sed 's|^usr/bin/||')"
|
||||
akm
|
||||
ChangeDisplayResolution
|
||||
RunInTerminal
|
||||
RunInTerminalEx
|
||||
UpdateInTerminal
|
||||
device-info
|
||||
eos-FindAppIcon
|
||||
eos-connection-checker
|
||||
eos-download-wallpapers
|
||||
eos-kbd-set
|
||||
eos-pkg-changelog
|
||||
eos-pkginfo
|
||||
eos-pkginfo-aur
|
||||
eos-sendlog
|
||||
eos-waiting-indicator
|
||||
eos-wallpaper-set
|
||||
paccache-service-manager
|
||||
su-c_wrapper
|
||||
eos-hooks-runner
|
||||
eos-reboot-required
|
||||
eos-reboot-required2
|
||||
eos-log-tool
|
||||
arch-news-for-you
|
||||
checkupdatesext
|
||||
eos-arch-news
|
||||
eos-update-notifier
|
||||
eos-update-notifier-configure
|
||||
eos-grub-fix-initrd-generation
|
||||
nvidia-installer-check
|
||||
nvidia-installer-update-db
|
||||
nvidia-installer-dkms
|
||||
pahis
|
||||
mirrorlist-rank-info
|
||||
reflector-simple
|
||||
#calamares-update
|
||||
eos-kill-yad-zombies
|
||||
eos-welcome
|
||||
welcome-dnd
|
||||
)
|
||||
local all="$(printf "%s\n" "${pkgs[@]}" "${apps[@]}" | /usr/bin/sort | /usr/bin/uniq)"
|
||||
|
||||
_eos-pkginfo_complete "$all"
|
||||
}
|
||||
complete -F _eos-pkginfo_ eos-pkginfo
|
||||
complete -F _eos-pkginfo_aur eos-pkginfo-aur
|
||||
@@ -0,0 +1,37 @@
|
||||
[Trigger]
|
||||
Operation = Upgrade
|
||||
Type = Package
|
||||
Target = amd-ucode
|
||||
Target = intel-ucode
|
||||
Target = btrfs-progs
|
||||
Target = cryptsetup
|
||||
Target = linux
|
||||
Target = linux-hardened
|
||||
Target = linux-lts
|
||||
Target = linux-zen
|
||||
Target = linux-rt
|
||||
Target = linux-rt-lts
|
||||
Target = linux-firmware*
|
||||
Target = nvidia
|
||||
Target = nvidia-dkms
|
||||
Target = nvidia-*xx-dkms
|
||||
Target = nvidia-*xx
|
||||
Target = nvidia-*lts-dkms
|
||||
Target = nvidia*-lts
|
||||
Target = mesa
|
||||
Target = systemd*
|
||||
Target = wayland
|
||||
Target = virtualbox-guest-utils
|
||||
Target = virtualbox-host-dkms
|
||||
Target = virtualbox-host-modules-arch
|
||||
Target = egl-wayland
|
||||
Target = xf86-video-*
|
||||
Target = xorg-server*
|
||||
Target = xorg-fonts*
|
||||
|
||||
[Action]
|
||||
Description = Check if user should be informed about rebooting after certain system package upgrades.
|
||||
When = PostTransaction
|
||||
Depends = libnotify
|
||||
NeedsTargets
|
||||
Exec = /usr/bin/eos-reboot-required2
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Avoid unnecessary reboots: don't notify if an updated package is
|
||||
# - not currently running (e.g. alternative kernel)
|
||||
# - not in use (e.g. alternative driver)
|
||||
|
||||
IsRunningKernel() {
|
||||
if [ -z "$running_kernel" ] ; then
|
||||
running_kernel=$(eos_running_kernel)
|
||||
fi
|
||||
test "$1" = "$running_kernel"
|
||||
}
|
||||
|
||||
DoNotify() {
|
||||
local cmd=(
|
||||
eos_notification_all # function to notify all users
|
||||
system-reboot # icon
|
||||
critical # urgency
|
||||
0 # expire time (not used!)
|
||||
eos-reboot-required2 # appname
|
||||
# title:
|
||||
"Reboot recommended!"
|
||||
# message:
|
||||
"Reboot is recommended due to the upgrade of core system package(s)."
|
||||
)
|
||||
"${cmd[@]}"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
Main() {
|
||||
local targets=$(cat) # list of updated package names from the hook (stdin)
|
||||
local target
|
||||
local running_kernel=""
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad --limit-icons || return
|
||||
|
||||
# do not notify if the updated package is not in use
|
||||
for target in $targets ; do
|
||||
case "$target" in
|
||||
linux | linux-lts | linux-zen | linux-hardened | linux-rt | linux-rt-lts | linux-lts?? | linux-lts???)
|
||||
# Note: only official and older LTS kernels are checked.
|
||||
if IsRunningKernel "$target" ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
nvidia)
|
||||
if IsRunningKernel linux ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
nvidia-lts)
|
||||
if IsRunningKernel linux-lts ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
amd-ucode)
|
||||
if [ "$(device-info --cpu)" = "AuthenticAMD" ] ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
intel-ucode)
|
||||
if [ "$(device-info --cpu)" = "GenuineIntel" ] ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
btrfs-progs)
|
||||
# Notify only if btrfs is in use
|
||||
if [ -n "$(/usr/bin/df -hT | awk '{print $2}' | grep -w btrfs)" ] ; then
|
||||
DoNotify
|
||||
fi
|
||||
;;
|
||||
wayland | egl-wayland)
|
||||
case "$XDG_SESSION_TYPE" in
|
||||
x11) ;;
|
||||
*) DoNotify ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
DoNotify
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Show whose password is needed and run 'su -c'.
|
||||
|
||||
Main()
|
||||
{
|
||||
printf "Root "
|
||||
/usr/bin/su -c "$@"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
@@ -0,0 +1,825 @@
|
||||
#!/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-install # $(eos_IconGrasp system-software-install)
|
||||
export WELCOME_ICON_PARTITION_MANAGER=gparted # $(eos_IconGrasp gparted)
|
||||
export WELCOME_ICON_BLUETOOTH=bluetooth # $(eos_IconGrasp bluetooth)
|
||||
export WELCOME_ICON_TOGGLE_r8169_DRIVER=system-software-update # $(eos_IconGrasp system-software-update)
|
||||
|
||||
export WELCOME_ICON_CHANGE_RESOLUTION=preferences-desktop-display
|
||||
export WELCOME_ICON_CHANGE_DISPLAY_MANAGER=preferences-desktop-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=software-update-available # or applications-internet ?
|
||||
export WELCOME_ICON_BLUETOOTH_INFO=$WELCOME_ICON_BLUETOOTH
|
||||
export WELCOME_ICON_LATEST_RELEASE=user-info # or info ?
|
||||
export WELCOME_ICON_INSTALLATION_TIPS=user-info
|
||||
export WELCOME_ICON_SYSTEM_RESCUE=user-info
|
||||
export WELCOME_ICON_SYSTEM_LOGS_HOWTO=user-info
|
||||
export WELCOME_ICON_WEBSITE=user-info # or info ?
|
||||
export WELCOME_ICON_WIKI=user-info
|
||||
export WELCOME_ICON_NEWS=user-info
|
||||
export WELCOME_ICON_FORUM=user-info
|
||||
export WELCOME_ICON_DONATE=user-info
|
||||
export WELCOME_ICON_ABOUT_WELCOME=user-info
|
||||
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=user-info
|
||||
export WELCOME_ICON_ARM=system-run
|
||||
export WELCOME_ICON_RUNINTERMINAL=preferences-system
|
||||
export WELCOME_ICON_QUESTION=dialog-question
|
||||
export WELCOME_ICON_INFO=dialog-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=notifications
|
||||
export WELCOME_ICON_NOTIFICATIONS_DISABLED=notifications-disabled
|
||||
|
||||
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<waitrounds; ix++)) ; do
|
||||
$checker >/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=info
|
||||
|
||||
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 "<span font='Mono$size'>%s</span>" "$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
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
### Configuration file for eos-script-lib-yad.
|
||||
###
|
||||
### To enable any setting below, simply remove the starting '#' character
|
||||
### on the appropriate line.
|
||||
|
||||
## Terminal program to be used by certain EndeavourOS packages
|
||||
## like 'welcome' and 'eos-update-notifier'.
|
||||
## Many popular terminals are supported. See a list of terminals known to be compatible
|
||||
## in file /usr/share/endeavouros/scripts/eos-script-lib-yad, function eos_yad_terminal().
|
||||
## If you have any of the listed terminals installed, EOS_YAD_TERMINAL need not be enabled.
|
||||
## Then the programs will use the first available program in the list.
|
||||
## Note: other than the listed terminals may or may not be compatible.
|
||||
#
|
||||
# EOS_YAD_TERMINAL="terminator"
|
||||
|
||||
## EOS_ROOTER configures the command for acquiring elevated privileges
|
||||
## when running commands in terminal.
|
||||
## Supported values:
|
||||
## "su"
|
||||
## "sudo"
|
||||
## "pkexec"
|
||||
## "su-c_wrapper"
|
||||
## Still supported values, but deprecated and will be removed in the future:
|
||||
## "su -c"
|
||||
## "pkexec bash -c"
|
||||
## "sudo bash -c"
|
||||
## "/usr/bin/su -c"
|
||||
## "/usr/bin/pkexec bash -c"
|
||||
## "/usr/bin/sudo bash -c"
|
||||
#
|
||||
export EOS_ROOTER="su"
|
||||
|
||||
## EOS_WELCOME_CONNECTION_WARNING specifies whether you want to allow the warning window
|
||||
## in the Welcome app about not being connected to the internet.
|
||||
## Supported values are: "yes" or "no".
|
||||
#
|
||||
EOS_WELCOME_CONNECTION_WARNING=yes
|
||||
|
||||
## EOS_CONNECTION_CHECKER selects the way how an internet connection availability is checked.
|
||||
## Supported values are: "ping" or "curl".
|
||||
## Note: "ping" may have problems if you are behind a proxy, thus "curl" is the default.
|
||||
#
|
||||
EOS_CONNECTION_CHECKER="curl"
|
||||
|
||||
## EOS_WIFIDEV_CHECK specifies if we want to make some ad hoc checks that we have the right
|
||||
## wifi card drivers installed. The checks are made in the Welcome app when using
|
||||
## the button "Detect system issues".
|
||||
## Supported values are "yes" or "no".
|
||||
#
|
||||
EOS_WIFIDEV_CHECK="yes"
|
||||
|
||||
## TERMINAL_AT_START, if set, causes the Welcome app to start a terminal always when
|
||||
## the Welcome app is started. The value should be an already installed terminal on your system.
|
||||
## Note that you can include any terminal specific options, for example:
|
||||
## TERMINAL_AT_START="xfce4-terminal --working-directory=$HOME/Downloads --geometry=+50+50"
|
||||
#
|
||||
# TERMINAL_AT_START="xfce4-terminal"
|
||||
|
||||
## EOS_KEEP_PKGS lists the names of packages that should not be removed when button
|
||||
## "Detect system issues" of the Welcome app is clicked.
|
||||
## For example:
|
||||
## EOS_KEEP_PKGS="intel-ucode xf86-video-intel"
|
||||
#
|
||||
# EOS_KEEP_PKGS=""
|
||||
|
||||
## EOS_AUR_HELPER contains the AUR helper program name.
|
||||
## Supported values are yay and paru, but other helpers may work as well.
|
||||
## The program must support options -Qua and -Sua.
|
||||
## For the Welcome app you can also set another AUR helper with
|
||||
## variable EOS_AUR_HELPER_OTHER.
|
||||
## Both apps must support the options mentioned above.
|
||||
#
|
||||
EOS_AUR_HELPER="yay"
|
||||
EOS_AUR_HELPER_OTHER="" # for example: "paru"
|
||||
|
||||
## EOS_WELCOME_PACDIFFER is an array of diff programs that can be used by pacdiff
|
||||
## (see man pacdiff) in Welcome.
|
||||
## Supported values are: kdiff3, kompare, diffuse, meld, code, diff, vim.
|
||||
## Other diff programs may work but are not tested (and may need additional support
|
||||
## by Welcome).
|
||||
## The array is written in preference order as only one of them is used.
|
||||
#
|
||||
EOS_WELCOME_PACDIFFERS=(meld kdiff3 kompare diffuse diff vim)
|
||||
|
||||
## EOS_PACDIFF_WARNING specifies whether a warning about the power of eos-pacdiff
|
||||
## will be shown or not when starting it.
|
||||
## Supported values: "yes" or "no".
|
||||
## Default: "yes".
|
||||
## Note: 'code' is not supported.
|
||||
#
|
||||
EOS_PACDIFF_WARNING=yes
|
||||
|
||||
## EOS_SUDO_EDITORS is an array of editor names that are suitable for
|
||||
## editing files with root permissions.
|
||||
## Currently they are used only in eos-update-notifier-configure.
|
||||
## Note that non-GUI editors (e.g. nano, emacs) are preferred for security reasons.
|
||||
## Currently editors known to work are:
|
||||
## - Non-GUI (preferred):
|
||||
## - nano
|
||||
## - emacs
|
||||
## - vim
|
||||
## - GUI (not preferred):
|
||||
## - leadpad
|
||||
## - xed
|
||||
## - geany
|
||||
## - mousepad (only with dbus-launch)
|
||||
## Other editors may work as well, but have not been tested.
|
||||
## The array is written in preference order as only one of them is used.
|
||||
#
|
||||
EOS_SUDO_EDITORS=(nano emacs vim)
|
||||
|
||||
## EOS_WALLPAPER_FETCHER selects the program to be used for downloading
|
||||
## certain additional wallpapers to EndeavourOS. These wallpapers (currently)
|
||||
## include the legacy wallpapers, and wallpapers created by the
|
||||
## EndeavourOS community.
|
||||
## Supported values: "git" or "curl". "git" is the default.
|
||||
## Of these, "curl" may be more suitable if bandwidth is limited.
|
||||
#
|
||||
EOS_WALLPAPER_FETCHER="git"
|
||||
|
||||
## EOS_WELCOME_HAS_SEE_YOU_LATER_BUTTON determines whether to show
|
||||
## the "See you later" button on the Welcome window.
|
||||
## Supported values: "yes" or "no"
|
||||
## Default: "no"
|
||||
#
|
||||
EOS_WELCOME_HAS_SEE_YOU_LATER_BUTTON=no
|
||||
|
||||
## EOS_FILESERVER_SITE specifies the site where certain documents and
|
||||
## small files will be fetched during the install phase, and when using the
|
||||
## installed system.
|
||||
## Supported values:
|
||||
## gitlab (default)
|
||||
## github
|
||||
#
|
||||
EOS_FILESERVER_SITE=gitlab
|
||||
|
||||
## SyncAfterUpdate specifies whether to call 'sync' after updating or not.
|
||||
## Possible values: "yes" or "no".
|
||||
## Default: "no".
|
||||
## Note: this setting was moved here from eos-update-notifier.conf at 2022-Apr-28.
|
||||
#
|
||||
SyncAfterUpdate=no
|
||||
|
||||
## EOS_UPDATE_ARCH_KEYRING_FIRST, if set to "yes", will try to update package
|
||||
## archlinux-keyring before updating other packages.
|
||||
## This may help with some PGP signature issues.
|
||||
## Note: this setting is used only in these apps:
|
||||
## - UpdateInTerminal
|
||||
## - welcome (via UpdateInTerminal)
|
||||
## Supported values:
|
||||
## no (default)
|
||||
## yes
|
||||
#
|
||||
EOS_UPDATE_ARCH_KEYRING_FIRST=no
|
||||
|
||||
## EOS_ICON_SETS_PREFERENCE array specifies the order of preference of the icon sets
|
||||
## you want to use in certain EndeavourOS apps.
|
||||
## The icon sets are folder names directly under /usr/share/icons.
|
||||
## The icon set names can be listed without path.
|
||||
## Default: all folders names found under /usr/share/icons
|
||||
## (note: not all of them contain icons...)
|
||||
#
|
||||
EOS_ICON_SETS_PREFERENCE=(
|
||||
# Add your preferred icon sets here.
|
||||
# For example:
|
||||
# Qogir Adwaita hicolor
|
||||
|
||||
# This is the default list of icon sets (note: in alphabetical order):
|
||||
/usr/share/icons/*
|
||||
)
|
||||
|
||||
## EOS_PREFERRED_BROWSERS is an ordered list of web browser apps.
|
||||
## EndeavourOS apps that use a web browser will look for this list first
|
||||
## when choosing a browser to use, unless there's a compelling reason to
|
||||
## use something else.
|
||||
##
|
||||
## Note that user can also export variables
|
||||
## _WELCOME_BROWSER
|
||||
## _WELCOME_BROWSER_OPTIONS
|
||||
## See file /usr/share/endeavouros/scripts/eos-scriptlib-yad and
|
||||
## function eos_select_browser() for more details.
|
||||
##
|
||||
## User can add own favorites anywhere into this list, and/or change the order.
|
||||
## The first matching app (the app must be installed!) in the list will be used.
|
||||
#
|
||||
EOS_PREFERRED_BROWSERS=( # search order for browsers
|
||||
xdg-open
|
||||
exo-open
|
||||
firefox
|
||||
chromium
|
||||
vivaldi-stable
|
||||
opera
|
||||
)
|
||||
|
||||
## RATE_MIRRORS_MAX_DELAY_ARCH is the max acceptable delay in seconds
|
||||
## since the last time a mirror has been synced. It is used only when ranking
|
||||
## the Arch mirrors with the 'rate-mirrors' program in Welcome.
|
||||
## Usually the range of reasonable values is somewhere between 60 and 3600.
|
||||
## The smaller the value, the less mirrors will match.
|
||||
## The bigger the value, the more mirrors will match.
|
||||
## If you want recently updated mirrors, use a small value (but not too small).
|
||||
## If no mirrors match, increase the value.
|
||||
## (Note that rate-mirrors defaults to 86400.)
|
||||
#
|
||||
RATE_MIRRORS_MAX_DELAY_ARCH=3600 # seconds
|
||||
|
||||
## EOS_LOCATION_PROVIDER_URL contains an URL for retrieving location info.
|
||||
## It is used by the 'show-location-info' app.
|
||||
## Alternatives known to work:
|
||||
## https://ipinfo.io (default, all features work)
|
||||
## https://ipapi.co (some features do not work)
|
||||
#
|
||||
EOS_LOCATION_PROVIDER_URL="https://ipinfo.io"
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is only meant to be called by Welcome at install.
|
||||
|
||||
WarnExit() {
|
||||
Msg2 "$1" warning
|
||||
exit 0
|
||||
}
|
||||
|
||||
Msg2() {
|
||||
local msg="$1"
|
||||
local type="$2"
|
||||
[ -n "$type" ] || type=info
|
||||
if [ "$LOGNAME" = "liveuser" ] && [ -x /usr/bin/calamares ] ; then
|
||||
echo "==> $progname: $type: $msg" >> $preprelogfile
|
||||
else
|
||||
echo "==> $progname: $type: $msg" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
SelectFileServer() {
|
||||
# Select file server for all code snippets
|
||||
|
||||
local progname="$(basename "$0")"
|
||||
local preprelogfile=/tmp/preprelog.txt
|
||||
case "$1" in
|
||||
--logfilename) echo "$preprelogfile"; return ;;
|
||||
esac
|
||||
rm -f $preprelogfile
|
||||
|
||||
# [ "$(id -u)" != "0" ] && return 0
|
||||
|
||||
if ! eos-connection-checker ; then
|
||||
WarnExit "internet connection not available"
|
||||
fi
|
||||
|
||||
local fserver=gitlab
|
||||
local place="$(show-location-info country 2>/dev/null)"
|
||||
|
||||
case "$place" in
|
||||
IR)
|
||||
# run for both liveuser and target
|
||||
fserver=github
|
||||
|
||||
sudo sed -i /etc/eos-script-lib-yad.conf -e "s|^EOS_FILESERVER_SITE=.*|EOS_FILESERVER_SITE=$fserver|"
|
||||
Msg2 "set EOS_FILESERVER_SITE to $fserver"
|
||||
;;
|
||||
esac
|
||||
echo "$fserver"
|
||||
}
|
||||
|
||||
SelectFileServer "$@"
|
||||
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Show information about GPUs and drivers
|
||||
# and send it to pastebin.
|
||||
#
|
||||
# Use option
|
||||
# -n for not to send to pastebin
|
||||
# -h for more information about the options
|
||||
#
|
||||
|
||||
DIE() {
|
||||
echo "$progname: error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Header() {
|
||||
local header="$1"
|
||||
printf "\n[%s]\n" "$header"
|
||||
}
|
||||
|
||||
Date() {
|
||||
Header "Date"
|
||||
/usr/bin/date "+%Y-%m-%d"
|
||||
}
|
||||
GPUs() {
|
||||
Header "Existing GPUs"
|
||||
/usr/bin/lspci -vnn | /usr/bin/grep -P 'VGA|3D|Display'
|
||||
}
|
||||
GPUKernelModules() {
|
||||
Header "GPU related kernel modules in use"
|
||||
/usr/bin/lsmod | /usr/bin/grep -P 'nvidia|nouveau|radeon|amdgpu|i915'
|
||||
}
|
||||
DriverFilter() {
|
||||
/usr/bin/grep -Pw "$pkgs_for_grep"
|
||||
}
|
||||
VideoDrivers() {
|
||||
Header "Installed video drivers and related packages"
|
||||
local pkg result
|
||||
local pkg_specs=( xf86-video
|
||||
nvidia
|
||||
prime
|
||||
optimus
|
||||
bbswitch
|
||||
bumblebee )
|
||||
local pkgs_for_grep="$(echo "${pkg_specs[*]}" | tr ' ' '|')"
|
||||
|
||||
for pkg in "${pkg_specs[@]}" ; do
|
||||
if [ "$testing" = "yes" ] ; then
|
||||
result=$(yay -Ss "$pkg" | grep ^[a-z]*/$pkg | DriverFilter)
|
||||
else
|
||||
result=$(/usr/bin/pacman -Qs "$pkg" | /usr/bin/grep ^local/ | /usr/bin/sed 's|^local/||' | DriverFilter)
|
||||
fi
|
||||
if [ -n "$result" ] ; then
|
||||
echo "$result"
|
||||
fi
|
||||
done | /usr/bin/sort | /usr/bin/uniq
|
||||
}
|
||||
All() {
|
||||
Date
|
||||
GPUs
|
||||
GPUKernelModules
|
||||
VideoDrivers
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local progname="$(basename "$0")"
|
||||
local testing="no" # "no" for release, "yes" for dev testing
|
||||
local send=yes
|
||||
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
cat <<EOF
|
||||
Usage: $progname [options]
|
||||
Options:
|
||||
--help This help.
|
||||
-h
|
||||
|
||||
--no-send Don't send to pastebin
|
||||
--dryrun
|
||||
-n
|
||||
|
||||
Without options the GPU info will be sent to pastebin which
|
||||
returns a URL where the information is saved.
|
||||
EOF
|
||||
return
|
||||
;;
|
||||
-n | --dryrun | --no-send)
|
||||
send=no
|
||||
;;
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
DIE "unsupported parameter '$1'"
|
||||
;;
|
||||
esac
|
||||
|
||||
local info=$(All) # get GPU infos
|
||||
|
||||
echo "$info" # show info locally
|
||||
[ "$send" = "yes" ] && echo "$info" | eos-sendlog # send info to pastebin
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+233
@@ -0,0 +1,233 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo2() { echo "$@" >&2 ; }
|
||||
printf2() { printf "$@" >&2 ; }
|
||||
|
||||
DIE() {
|
||||
echo2 "$progname: error: $1"
|
||||
if [ -z "$2" ] ; then
|
||||
exit 1
|
||||
else
|
||||
exit "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
Options() {
|
||||
local arg
|
||||
for arg in "$@" ; do
|
||||
case "$arg" in
|
||||
-h | --help)
|
||||
cat <<EOF
|
||||
Directs standard input into a service at address
|
||||
$EOS_SENDLOG_URI
|
||||
and saves returned URLs into file
|
||||
$db2
|
||||
See file $configfile about how to configure the service address.
|
||||
|
||||
Usage: $progname [options]
|
||||
options:
|
||||
-n | --nosave Don't save returned URL.
|
||||
-h | --help This help.
|
||||
--man Show manual at $EOS_SENDLOG_URI.
|
||||
-v | --verbose Show more info about the operation.
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
--man)
|
||||
xdg-open "$EOS_SENDLOG_URI"
|
||||
exit 0
|
||||
;;
|
||||
-n | --nosave)
|
||||
save=no
|
||||
;;
|
||||
-v | --verbose)
|
||||
verbose=yes
|
||||
;;
|
||||
# -f=* | --file=*) inputfile="${arg#*=}" ;;
|
||||
-*) DIE "unsupported option '$arg'" ;;
|
||||
*) DIE "unsupported parameter '$arg'" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
SendToNet1() {
|
||||
local ix="$1"
|
||||
[ -n "$ix" ] || return 1
|
||||
local srv="${supported_uris[$ix]}"
|
||||
local form="${supported_uris[$((ix+1))]}"
|
||||
[ -n "$srv" ] || return 1
|
||||
|
||||
case "$form" in
|
||||
"") [ "$srv" != "wgetpaste" ] && return 1 ;;
|
||||
esac
|
||||
|
||||
[ "$verbose" = "yes" ] && printf2 "==> $srv: "
|
||||
|
||||
local exitcode=0
|
||||
local msgs=()
|
||||
local msg1="warning: sending data to"
|
||||
local msg2="failed with code "
|
||||
|
||||
case "$srv" in
|
||||
wgetpaste)
|
||||
if [ -x /usr/bin/wgetpaste ] ; then
|
||||
url=$(wgetpaste $WGETPASTE_OPTIONS 2>/dev/null)
|
||||
exitcode=$?
|
||||
if [ $exitcode -ne 0 ] ; then
|
||||
msgs+=("$msg1 $srv $msg2 $exitcode.")
|
||||
[ "$verbose" = "yes" ] && echo2 "failed"
|
||||
fi
|
||||
else
|
||||
msgs+=("warning: sorry, package wgetpaste-eos is not installed!")
|
||||
exitcode=1
|
||||
[ "$verbose" = "yes" ] && echo2 "failed"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
url=$(curl --fail -Lsm 30 -F "${form}" "$srv" 2>/dev/null)
|
||||
exitcode=$?
|
||||
if [ $exitcode -ne 0 ] ; then
|
||||
msgs+=("$msg1 $srv $msg2 $exitcode.")
|
||||
[ "$verbose" = "yes" ] && echo2 "failed"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ $exitcode -eq 0 ] ; then
|
||||
[ "$verbose" = "yes" ] && echo2 "OK"
|
||||
return 0 # OK
|
||||
else
|
||||
[ "$verbose" = "yes" ] && {
|
||||
echo2 ""
|
||||
printf2 "%s\n" "${msgs[@]}"
|
||||
}
|
||||
return $exitcode
|
||||
fi
|
||||
}
|
||||
|
||||
SendToNet() {
|
||||
local exitcode=0
|
||||
local ix=$default_ix
|
||||
local failed=()
|
||||
|
||||
# try the user default first
|
||||
SendToNet1 "$ix" && return
|
||||
|
||||
for ((ix=0; ix < ${#supported_uris[@]}; ix+=2)) ; do
|
||||
case "$ix" in
|
||||
$default_ix) # already tested
|
||||
;;
|
||||
*) SendToNet1 "$ix" && return
|
||||
[ "$verbose" = "no" ] && failed+=("${supported_uris[$ix]}")
|
||||
;;
|
||||
esac
|
||||
sleep 2
|
||||
done
|
||||
if [ "$verbose" = "yes" ] ; then
|
||||
DIE "sorry, all configured pastebin like services failed!"
|
||||
else
|
||||
DIE "sorry, all configured pastebin like services ${failed[*]} failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
Init() {
|
||||
local ix
|
||||
|
||||
[ -r $configfile ] && source $configfile
|
||||
|
||||
EOS_SENDLOG_URI="" # no more used!
|
||||
|
||||
return
|
||||
|
||||
# set default_ix based on possible EOS_SENDLOG_URI
|
||||
if [ -n "$EOS_SENDLOG_URI" ] ; then
|
||||
for ((ix=0; ix < ${#supported_uris[@]}; ix+=2)) ; do
|
||||
if [ "$EOS_SENDLOG_URI" = "${supported_uris[$ix]}" ] ; then
|
||||
default_ix=$ix
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
Main_old() {
|
||||
local progname="$(basename "$0")"
|
||||
local configfile=/etc/eos-sendlog.conf
|
||||
|
||||
local default_ix=0 # was 1
|
||||
|
||||
# 'supported_uris' lists the pastebin like services supported by this app.
|
||||
#
|
||||
local supported_uris=( # and forms
|
||||
"https://0x0.st" 'file=@-' # default
|
||||
"wgetpaste" '' # use another program!
|
||||
"http://ix.io" 'f:1=<-'
|
||||
|
||||
# "https://clbin.com" "clbin=<-" # has serious problems?
|
||||
)
|
||||
local EOS_SENDLOG_URI=""
|
||||
local WGETPASTE_OPTIONS="--nick nobody"
|
||||
|
||||
# from config file (if values are set, they must be correct!):
|
||||
Init
|
||||
|
||||
local save=yes
|
||||
local verbose=no
|
||||
local inputfile=""
|
||||
local db="$HOME/.config/$progname.txt"
|
||||
local db2='$HOME'/.config/$progname.txt
|
||||
local url
|
||||
|
||||
Options "$@"
|
||||
|
||||
if [ -n "$inputfile" ] ; then
|
||||
cat "$inputfile" | SendToNet || return $? # this line doesn't work...
|
||||
else
|
||||
SendToNet
|
||||
fi
|
||||
|
||||
if [ "$save" = "yes" ] ; then
|
||||
local current_db=""
|
||||
[ -r "$db" ] && current_db="$(cat "$db")"
|
||||
printf "%s: %s\n" "$(date +%Y%m%d-%H%M)" "$url" > $db
|
||||
[ -n "$current_db" ] && echo "$current_db" >> $db
|
||||
fi
|
||||
echo "$url"
|
||||
}
|
||||
|
||||
Main() {
|
||||
local progname="${0##*/}"
|
||||
local logfile="$HOME/$progname.log"
|
||||
|
||||
# pastebin providers
|
||||
_0x0.st() { curl -F'file=@-' https://0x0.st ; }
|
||||
_ix.io() { curl -F'f:1=<-' ix.io | tee -a "$logfile" ; } # no https at 2023-06-20
|
||||
_wgetpaste() {
|
||||
if [ ! -x /bin/wgetpaste ] ; then
|
||||
echo "$progname: warning: wgetpaste-eos not installed" >&2
|
||||
return 1
|
||||
fi
|
||||
local exitcode=0 output
|
||||
output=$(echo "$input" | wgetpaste -n anonymous)
|
||||
exitcode=$?
|
||||
if [ $exitcode -eq 0 ] ; then
|
||||
echo "$output"
|
||||
echo "$(date "+%Y-%m-%d"): $output" >> "$logfile"
|
||||
else
|
||||
echo "==> $progname: warning: wgetpaste failed, code $exitcode." >&2
|
||||
return $exitcode
|
||||
fi
|
||||
}
|
||||
|
||||
# run one of them
|
||||
local input=$(cat)
|
||||
if [ -z "$input" ] ; then
|
||||
echo "==> $progname: warning: nothing to send." >&2
|
||||
return 1
|
||||
fi
|
||||
# echo "$input" | _0x0.st 2>/dev/null && return # fails at 2023-06-20
|
||||
_wgetpaste 2>/dev/null && return
|
||||
echo "$input" | _ix.io 2>/dev/null && return
|
||||
echo "$progname: warning: configured pastebin sites failed." >&2
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Configuration file for command eos-sendlog.
|
||||
#
|
||||
# Please do NOT use eos-sendlog to save anything large, like
|
||||
# pictures, videos, game backups, ISO files, etc.
|
||||
|
||||
# WGETPASTE_OPTIONS value contains any options from the user.
|
||||
# Default option string for wgetpaste is
|
||||
# "--nick nobody"
|
||||
# if not changed below.
|
||||
#
|
||||
# WGETPASTE_OPTIONS="--nick nobody"
|
||||
|
||||
# EOS_SENDLOG_URI is no more used because of problems
|
||||
# with several pastebin like services.
|
||||
# Instead, the eos-sendlog app uses certain well-known
|
||||
# services. See /usr/bin/eos-sendlog.
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script enables an after-the-fact timeshift equivalent for Arch systems
|
||||
# Give it a date (as in 2020-09-20) and it will use the Arch archive repos
|
||||
# to revert to the package state that applied on that date.
|
||||
#
|
||||
# Note: no AUR package will be reverted.
|
||||
#
|
||||
# 21 September 2020 - freebird54
|
||||
# 21 July 2021 - changes by manuel
|
||||
#
|
||||
|
||||
# Get some useful definitions:
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || exit 1
|
||||
export -f eos_yad
|
||||
export -f eos_GetProgName
|
||||
export -f eos_GetArch
|
||||
# EOS_ROOTER
|
||||
|
||||
DIE() {
|
||||
local msg="$1"
|
||||
local title="$2" # optional, default is "Error"
|
||||
[ -n "$title" ] || title="Error"
|
||||
echo "$1" | eos_yad --text-info --title="$title" --text="Message from '$progname':" --image=error --button=yad-quit
|
||||
exit 1
|
||||
}
|
||||
STOP() { DIE "$1" Warning; }
|
||||
|
||||
DateValidityCheck() {
|
||||
[ -n "$REVERTDATE" ] || exit 1 # No date selected.
|
||||
[ "$REVERTDATE" = "$stopdate" ] && STOP "Current date selected, nothing to do."
|
||||
curl -Lsm 10 -o/dev/null --fail "$urlbase" || DIE "Archive at $REVERTDATE not found!"
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local progname="$(eos_GetProgName)"
|
||||
case "$(eos_GetArch)" in
|
||||
x86_64) ;;
|
||||
*) DIE "This program is supported only on x86_64 machines." ;; # because of mirrors...
|
||||
esac
|
||||
local date=$(/usr/bin/date +%Y%m%d-%H%M) # for temporary backup file
|
||||
local stopdate="$(/usr/bin/date +%Y/%m/%d)" # for checking if user selected this date
|
||||
local mlist=/etc/pacman.d/mirrorlist
|
||||
local bak="$mlist.$progname.$date"
|
||||
local txt="This app can revert (downgrade) packages of this system to the state they were in\non the selected date.\n"
|
||||
txt+="Note: AUR packages will <i>not</i> be reverted.\n\n"
|
||||
txt+="Please select the date to revert your packages to.\n"
|
||||
local REVERTDATE=$(eos_yad --calendar --title "Select Date" --text="$txt" --image=dialog-question --date-format=%C%y/%m/%d \
|
||||
--button='yad-cancel!!Do nothing':1 --button='Revert!dialog-yes!Downgrade':0)
|
||||
local urlbase="https://archive.archlinux.org/repos/$REVERTDATE"
|
||||
local cmd=""
|
||||
local cmd2=""
|
||||
local tmpmlist
|
||||
|
||||
DateValidityCheck
|
||||
|
||||
# Create a temporary mirrorlist for the specified date.
|
||||
tmpmlist=$(mktemp)
|
||||
printf "## Reversion mirrorlist\n\n" > $tmpmlist
|
||||
printf "%s\n\n" "Server = $urlbase/\$repo/os/\$arch" >> $tmpmlist
|
||||
|
||||
cmd="mv $mlist '$bak'" # Backups original mirrorlist and
|
||||
cmd+=";mv $tmpmlist $mlist" # uses the reverted list.
|
||||
cmd+=";pacman -Syyuu" # Runs the 'downdate' command.
|
||||
cmd+=";mv '$bak' $mlist" # Restores the original mirrorlist from backup.
|
||||
cmd+=";chmod 0644 $mlist" # Make sure mirrorlist has proper permissions.
|
||||
|
||||
cmd2="$(echo "$cmd" | tr ';' '\n' | sed 's|^| |')"
|
||||
RunInTerminal "printf 'Reverting all packages to $REVERTDATE\n\n'; echo 'Need elevated privileges to run commands:'; echo '$cmd2'; $EOS_ROOTER '$cmd'"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# After each second, show seconds remaining until this program exists.
|
||||
#
|
||||
# The output is displayed on one line.
|
||||
# Pressing any key will stop this program.
|
||||
#
|
||||
# Exit code is
|
||||
# - 0 if any regular key was pressed
|
||||
# - 130 if the program was interrupted with Ctrl-C
|
||||
# - 142 if timeout occurred
|
||||
#
|
||||
# Parameters:
|
||||
# $1 = number of seconds (integer) before the program exists
|
||||
# $2 = (optional) prompt to show before showing the remaining seconds
|
||||
|
||||
printf2() { printf "$@" >&2 ; }
|
||||
|
||||
ShowTime() {
|
||||
CountOfSubtrings() {
|
||||
# how many "substring"s there are in the given "string"
|
||||
local string="$1"
|
||||
local substring="$2"
|
||||
local length=${#string}
|
||||
local sublength=${#substring}
|
||||
|
||||
string=${string//$substring/}
|
||||
local newlength=${#string}
|
||||
return $(( (length - newlength) / sublength ))
|
||||
}
|
||||
|
||||
CountOfSubtrings "$prompt" "%s"
|
||||
case "$?" in
|
||||
1) printf2 "\r$prompt\r" "$s" ;;
|
||||
2) printf2 "\r$prompt\r" "$s" "$seconds" ;;
|
||||
*) printf2 "unsupported prompt '%s'\n" "$prompt" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Main() {
|
||||
local -r seconds="$1"
|
||||
local prompt="$2"
|
||||
local s
|
||||
local ret=0
|
||||
local str=""
|
||||
|
||||
[ -n "$prompt" ] || prompt="[Close in %s/%s seconds (or press a key to close)]"
|
||||
|
||||
for ((s=seconds; s>0; s--)) ; do
|
||||
ShowTime
|
||||
read -t1 -n1 str
|
||||
ret=$?
|
||||
[ $ret -eq 0 ] && break
|
||||
done
|
||||
ShowTime
|
||||
if [ $ret -ne 0 ] || [ -n "$str" ] ; then
|
||||
printf2 "\n"
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Package updater for EndeavourOS and Arch.
|
||||
# Handles db lock file, keyrings, syncing, and optionally AUR with given AUR helper.
|
||||
|
||||
Options() {
|
||||
local opts
|
||||
local lopts="nvidia,helper:,min-free-bytes:,paru,yay,pacman,help"
|
||||
local sopts="h"
|
||||
|
||||
opts="$(/usr/bin/getopt -o=$sopts --longoptions $lopts --name "$progname" -- "$@")" || {
|
||||
Options -h
|
||||
return 1
|
||||
}
|
||||
eval set -- "$opts"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
--nvidia)
|
||||
if IsEndeavourOS ; then
|
||||
nvidia=eos-kernel-nvidia-update-check
|
||||
else
|
||||
echo "Sorry, option $1 works only in EndeavourOS. Option ignored." >&2
|
||||
fi
|
||||
;;
|
||||
--min-free-bytes) min_free_bytes="$2" ; shift ;;
|
||||
--helper) helper="$2" ; shift ;;
|
||||
--paru | --yay | --pacman) helper="${1/--/}" ;;
|
||||
|
||||
-h | --help)
|
||||
cat <<EOF >&2
|
||||
Package updater for EndeavourOS and Arch
|
||||
Handles:
|
||||
- disk space check
|
||||
- pacman db lock
|
||||
- keyrings
|
||||
- sync after update
|
||||
and optionally
|
||||
- AUR with given AUR helper
|
||||
- Nvidia driver vs. kernel updates (only on EndeavourOS)
|
||||
|
||||
Usage: $progname [options]
|
||||
Options:
|
||||
--help, -h This help.
|
||||
--nvidia Check also nvidia driver vs. kernel updates.
|
||||
--helper AUR helper name. Supported: yay, paru, pacman. Default: pacman.
|
||||
Others supporting option -Sua should work as well.
|
||||
--paru Same as --helper=paru.
|
||||
--yay Same as --helper=yay.
|
||||
--pacman Same as --helper=pacman. Default.
|
||||
--min-free-bytes Minimal amount of free space (in bytes) that the root partition should have
|
||||
before updating. Otherwise a warning message will be displayed.
|
||||
Default: $min_free_bytes
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
IsEndeavourOS() {
|
||||
if [ "$isEndeavourOS" = "yes" ] || [ -r /usr/lib/endeavouros-release ] || [ -n "$(grep -iw endeavouros /etc/*-release)" ] ; then
|
||||
isEndeavourOS=yes
|
||||
return 0
|
||||
fi
|
||||
isEndeavourOS=no
|
||||
return 1
|
||||
}
|
||||
|
||||
DiskSpace() {
|
||||
local available=$(LANG=C /usr/bin/df | /usr/bin/grep -w "/" | /usr/bin/awk '{print $4}')
|
||||
local min=$((min_free_bytes / 1000)) # use compatible numbers
|
||||
|
||||
if [ $available -lt $min ] ; then
|
||||
{
|
||||
echo "WARNING: your root partition (/) has only $available bytes of free space."
|
||||
if [ $(du -d0 /var/cache/pacman/pkg | awk '{print $1}') -gt $min ] ; then
|
||||
printf "\nFor example, cleaning up the package cache may help.\n"
|
||||
printf "Command 'sudo paccache -rk1' would do this:"
|
||||
paccache -dk1
|
||||
printf "Command 'sudo paccache -ruk0' would do this:"
|
||||
paccache -duk0
|
||||
echo ""
|
||||
fi
|
||||
} >&2
|
||||
fi
|
||||
}
|
||||
|
||||
Main() {
|
||||
local progname="$(/usr/bin/basename "$0")"
|
||||
local nvidia=":"
|
||||
local helper="pacman"
|
||||
local min_free_bytes=$((1000 * 1000 * 1000)) # default: 1 GB
|
||||
|
||||
local helper2=":"
|
||||
local lock=/var/lib/pacman/db.lck
|
||||
local rmopt=f
|
||||
local isEndeavourOS=""
|
||||
|
||||
Options "$@"
|
||||
|
||||
echo "$helper update with additional and useful checks" >&2
|
||||
|
||||
DiskSpace
|
||||
|
||||
if [ -e $lock ] && fuser $lock &>/dev/null ; then
|
||||
rmopt=i
|
||||
fi
|
||||
local keyrings=(archlinux-keyring)
|
||||
IsEndeavourOS && keyrings+=(endeavouros-keyring)
|
||||
echo "Updating..."
|
||||
if [ "$helper" = "pacman" ] ; then
|
||||
sudo bash -c "rm -$rmopt $lock; [ -e $lock ] || { $nvidia && pacman -Sy --noconfirm --needed ${keyrings[*]} && pacman -Su && sync ; }"
|
||||
else
|
||||
helper2="/usr/bin/sudo -u $LOGNAME $helper -Sua"
|
||||
sudo bash -c "rm -$rmopt $lock; [ -e $lock ] || { $nvidia && pacman -Sy --noconfirm --needed ${keyrings[*]} && pacman -Su && $helper2 ; sync ; }"
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Show a waiting indicator on the terminal.
|
||||
# Usage: eos-waiting-indicator lock-file
|
||||
|
||||
DIE() {
|
||||
echo "Error: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
ShowIndicator() {
|
||||
local str items
|
||||
# items=( "◡◡" "⊙⊙" "◠◠" )
|
||||
# items=( "◴" "◷" "◶" "◵" )
|
||||
# items=( "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃" "▁" )
|
||||
items=( "◢" "◣" "◤" "◥" )
|
||||
|
||||
tput civis # hide cursor
|
||||
#printf "%s\n" "$prompt" >&2
|
||||
case "$1" in
|
||||
-nl) printf "\n" >&2 ;;
|
||||
esac
|
||||
while true ; do
|
||||
for str in "${items[@]}" ; do
|
||||
printf "\r%s %s" "$prompt" "$str" >&2
|
||||
if [ ! -r "$lockfile" ] ; then
|
||||
tput cnorm # unhide cursor
|
||||
return
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local lockfile="$1"
|
||||
local prompt="$2"
|
||||
|
||||
[ -n "$lockfile" ] || DIE "lockfile argument missing"
|
||||
[ -r "$lockfile" ] || DIE "lockfile does not exist"
|
||||
|
||||
ShowIndicator -nl
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+324
@@ -0,0 +1,324 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage: eos-wallpaper-set [filename]
|
||||
# where
|
||||
# filename Picture file name (optional).
|
||||
#
|
||||
# Without filename, assumes all wallpapers are at /usr/share/endeavouros/backgrounds.
|
||||
|
||||
#################################################################################
|
||||
EOS_SCRIPTS_YAD=/usr/share/endeavouros/scripts/eos-script-lib-yad
|
||||
source $EOS_SCRIPTS_YAD || {
|
||||
echo "ERROR: cannot read $EOS_SCRIPTS_YAD" >&2
|
||||
exit 1
|
||||
}
|
||||
unset EOS_SCRIPTS_YAD
|
||||
|
||||
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
|
||||
#################################################################################
|
||||
|
||||
Monospaced() { printf "<tt>%s</tt>" "$1" ; }
|
||||
Untagged() { echo "$1" | sed -e 's|<[/]*[ib]>||g' ; }
|
||||
|
||||
eos_yad_infomsg() {
|
||||
local msg="$1"
|
||||
Untagged "$msg" >&2
|
||||
eos_yad --form --text="$(Monospaced "$msg")" --title="Message" --tail --wrap --image=info \
|
||||
--button=yad-quit:0 "$@"
|
||||
}
|
||||
|
||||
DIE() {
|
||||
Untagged "$1" >&2
|
||||
eos_yad --form --text="$(Monospaced "$1")\n" --title="$progname: error" \
|
||||
--width=400 \
|
||||
--image=error --button=yad-ok:0
|
||||
exit 1
|
||||
}
|
||||
|
||||
WallpaperSelect() {
|
||||
local pic_count=$(/usr/bin/ls -l "$picfolder" | /usr/bin/wc -l)
|
||||
local height=$((pic_count * 36))
|
||||
local hmax=600 hmin=300
|
||||
|
||||
if [ $height -gt $hmax ] ; then
|
||||
height=$hmax
|
||||
elif [ $height -lt $hmin ] ; then
|
||||
height=$hmin
|
||||
fi
|
||||
|
||||
pic="$(eos_yad --file --filename="$picfolder" --width=700 --height=$height --title="Choose wallpaper file")"
|
||||
test $? -eq 0 || exit 1
|
||||
}
|
||||
|
||||
XfceSetWallpaper() {
|
||||
# Set all "last-image" values in file $conf to picture $pic
|
||||
|
||||
local impl
|
||||
|
||||
case "$(eos_GetArch)" in
|
||||
armv7h) impl=1 ;;
|
||||
*) impl=2 ;; # 2 = best for x86_64 (?)
|
||||
esac
|
||||
|
||||
case "$impl" in
|
||||
0)
|
||||
local conf="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml"
|
||||
test -r "$conf" || DIE "Config file '$conf' does not exist."
|
||||
sed -i "$conf" -e 's|name="last-image".*$|name="last-image" type="string" value="'"$pic"'"/>|'
|
||||
eos_yad_infomsg "Reboot is required for the changes to take effect."
|
||||
;;
|
||||
1)
|
||||
local prop
|
||||
for prop in $(xfconf-query --channel xfce4-desktop --list | grep /last-image$) ; do
|
||||
xfconf-query --channel xfce4-desktop --property $prop --set "$pic"
|
||||
done
|
||||
#eos_yad_infomsg "Reboot is required for the changes to take effect."
|
||||
;;
|
||||
2)
|
||||
local monitors=($(xrandr | grep -w connected | awk '{print $1}'))
|
||||
local monitor mon prop
|
||||
|
||||
for monitor in "${monitors[@]}" ; do
|
||||
mon=monitor${monitor}
|
||||
prop=$(xfconf-query --channel xfce4-desktop --list | grep /last-image$ | grep $mon)
|
||||
xfconf-query --channel xfce4-desktop --property $prop --set "$pic"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
WallpaperSetCommon() {
|
||||
# Assume:
|
||||
# - $pic is the picture file name
|
||||
# - $DE is the desktop environment
|
||||
|
||||
test -n "$pic" || DIE "no picture!"
|
||||
|
||||
case "$DE" in
|
||||
BUDGIE)
|
||||
AssertPicture endeavouros_budgie.png
|
||||
gsettings set org.gnome.desktop.background picture-uri "$pic"
|
||||
;;
|
||||
CINNAMON)
|
||||
AssertPicture endeavouros_cinnamon.png
|
||||
gsettings set org.cinnamon.desktop.background picture-uri "$pic"
|
||||
;;
|
||||
DEEPIN)
|
||||
AssertPicture endeavouros_deepin.png
|
||||
dconf write /com/deepin/wrap/gnome/desktop/background/picture-uri "'$pic'" # Note: extra quotes required!
|
||||
;;
|
||||
GNOME | GNOME3)
|
||||
AssertPicture endeavouros_gnome.png
|
||||
gsettings set org.gnome.desktop.background picture-uri "$pic"
|
||||
;;
|
||||
I3)
|
||||
AssertPicture endeavouros_i3.png no
|
||||
feh --bg-scale "$pic"
|
||||
;;
|
||||
KDE)
|
||||
AssertPicture endeavouros_plasma.png no
|
||||
python3 /usr/share/endeavouros/scripts/ksetwallpaper.py --file "$pic"
|
||||
# see also:
|
||||
# https://www.kubuntuforums.net/showthread.php/66762-Right-click-wallpaper-changer?p=387392&viewfull=1#post387392
|
||||
;;
|
||||
LXDE)
|
||||
AssertPicture endeavouros_lxde.png no
|
||||
pcmanfm --set-wallpaper="$pic"
|
||||
;;
|
||||
LXQT)
|
||||
AssertPicture endeavouros_lxqt.png no
|
||||
pcmanfm-qt --set-wallpaper="$pic"
|
||||
;;
|
||||
MATE)
|
||||
AssertPicture endeavouros_mate.png no
|
||||
gsettings set org.mate.background picture-filename "$pic"
|
||||
;;
|
||||
XFCE)
|
||||
AssertPicture endeavouros_xfce4.png no
|
||||
XfceSetWallpaper
|
||||
;;
|
||||
|
||||
# Not DEs but WMs:
|
||||
|
||||
SWAY)
|
||||
AssertPicture endeavouros-wallpaper.png no
|
||||
killall swaybg # otherwise wallpaper doesn't change!
|
||||
swaybg -i "$pic"
|
||||
;;
|
||||
BSPWM)
|
||||
AssertPicture endeavouros-wallpaper.png no
|
||||
nitrogen --set-auto "$pic"
|
||||
;;
|
||||
OPENBOX)
|
||||
AssertPicture endeavouros-wallpaper.png no
|
||||
nitrogen --set-auto "$pic"
|
||||
;;
|
||||
QTILE)
|
||||
AssertPicture endeavouros-wallpaper.png no
|
||||
feh --bg-scale "$pic"
|
||||
;;
|
||||
*)
|
||||
echo "$progname: info: not setting wallpaper to $DE ..." >&2
|
||||
|
||||
#AssertPicture endeavouros-wallpaper.png no
|
||||
#feh --bg-scale "$pic"
|
||||
#DIE "Sorry, desktop '$DE' is not supported."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
PictureNameVariations() {
|
||||
# Allow very small naming choices in the default wallpapers,
|
||||
# like '-' instead of '_' before the DE name.
|
||||
|
||||
[ -r "$pic" ] && return # picture found, OK
|
||||
|
||||
if [ "$(basename "$pic")" = "$fallback" ] ; then
|
||||
local changed="$(echo "$pic" | sed 's|endeavouros_\([a-z][a-z]*[0-9]\.png\)$|endeavouros-\1|')"
|
||||
if [ -r "$changed" ] ; then
|
||||
echo "Info: wallpaper name changed from '$(basename "$pic")' to '$(basename "$changed")'" >&2
|
||||
pic="$changed"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
DIE "Picture file '$pic' does not exist."
|
||||
}
|
||||
|
||||
AssertPicture() {
|
||||
local fallback="$1"
|
||||
local use_file_prefix="$2"
|
||||
|
||||
case "$pic" in
|
||||
DEFAULT-2020 | default-2020)
|
||||
case "$(eos_GetArch)" in
|
||||
armv7h)
|
||||
pic="$picfolder/arm-$fallback"
|
||||
[ -r "$pic" ] || pic="$picfolder/$fallback" # ARM pictures missing
|
||||
;;
|
||||
*)
|
||||
pic="$picfolder/$fallback"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
DEFAULT | default | DEFAULT-2021 | default-2021)
|
||||
pic="$picfolder/endeavouros-wallpaper.png"
|
||||
;;
|
||||
ISO | iso)
|
||||
pic="$picfolder/endeavouros-default-background.png" # new picture
|
||||
[ -r "$pic" ] || pic="$picfolder/endeavouros-wallpaper.png" # old picture
|
||||
;;
|
||||
esac
|
||||
|
||||
# change $pic to full path format
|
||||
case "$pic" in
|
||||
"")
|
||||
DIE "no picture file given!"
|
||||
;;
|
||||
file://*)
|
||||
pic="${pic:7}"
|
||||
;;
|
||||
/*)
|
||||
;; # OK, full path
|
||||
*)
|
||||
if [ -r "$picfolder/$pic" ] ; then
|
||||
pic="$picfolder/$pic" # EOS picture without path given, add path
|
||||
elif [ -r "$pic" ] ; then
|
||||
pic="$PWD/$pic" # picture has relative path
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we have a full path. Check that it exists or die.
|
||||
PictureNameVariations
|
||||
|
||||
# Some DE's prefer file:// prefix, some not.
|
||||
if [ "$use_file_prefix" = "no" ] ; then
|
||||
case "$pic" in
|
||||
file://*) pic="${pic:7}" ;;
|
||||
esac
|
||||
else
|
||||
case "$pic" in
|
||||
file://*) ;;
|
||||
*) pic="file://$pic" ;;
|
||||
esac
|
||||
fi
|
||||
echo "Setting desktop wallpaper $pic for '$DE' ..." >&2
|
||||
}
|
||||
|
||||
Parameters() {
|
||||
local arg msg
|
||||
|
||||
for arg in "$@" ; do
|
||||
case "$arg" in
|
||||
-h | --help)
|
||||
eos_yad_infomsg "$(Usage)"
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
msg="$(printf "\n%s\n\n" "Unsupported option '$arg'." ; Usage)"
|
||||
DIE "$msg"
|
||||
;;
|
||||
*)
|
||||
if [ -d "$arg" ] ; then
|
||||
picfolder="$arg"
|
||||
else
|
||||
pic="$arg"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
Usage: <b>$progname</b> [wallpaper-file | folder]
|
||||
where
|
||||
<i>wallpaper-file</i>
|
||||
Wallpaper file name, 'DEFAULT', or 'ISO':
|
||||
- absolute or relative path, with or without leading 'file://'.
|
||||
- 'DEFAULT' means the default Desktop specific wallpaper.
|
||||
- 'ISO' means the default wallpaper for the installer ISO
|
||||
<i>folder</i>
|
||||
An existing folder path for wallpapers.
|
||||
|
||||
If <i>wallpaper-file</i> is not given, the <i>wallpaper chooser</i> is started.
|
||||
|
||||
Examples:
|
||||
$progname ~/Pictures/a_picture.jpg # wallpaper file name
|
||||
$progname ~/Pictures # folder path for pictures
|
||||
$progname DEFAULT # Desktop specific default wallpaper
|
||||
$progname ISO # wallpaper used by the ISO
|
||||
$progname # starts the wallpaper chooser
|
||||
EOF
|
||||
}
|
||||
|
||||
Main()
|
||||
{
|
||||
local progname="$(basename "$0")"
|
||||
local DE="$(eos_GetDeOrWm)"
|
||||
local picfolder=/usr/share/endeavouros/backgrounds
|
||||
local pic=""
|
||||
|
||||
case "$DE" in
|
||||
XFCE) type xrandr >& /dev/null || DIE "Sorry, this implementation needs package 'xorg-xrandr' on Xfce." ;;
|
||||
esac
|
||||
|
||||
Parameters "$@"
|
||||
|
||||
if [ -z "$pic" ] ; then
|
||||
WallpaperSelect
|
||||
fi
|
||||
WallpaperSetCommon
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+165
@@ -0,0 +1,165 @@
|
||||
#/bin/bash
|
||||
|
||||
# Choose grub menu colours with arrow keys in the preview.
|
||||
# Changes will be saved in file /etc/default/grub.
|
||||
# After reboot you'll see the changes in the grub menu.
|
||||
|
||||
etcdefaultgrubfile="/etc/default/grub"
|
||||
grubconffile="/boot/grub/grub.cfg"
|
||||
|
||||
function cleanup() {
|
||||
rm -f -- "$tmpfile"
|
||||
printf '\e[?25h' # unhide cursor
|
||||
stty echo
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
readonly tmpfile="$(mktemp default-grub-temp-XXXXXX)"
|
||||
|
||||
set -e # fail on first error
|
||||
|
||||
stty -echo
|
||||
printf '\e[?25l' # hide cursor
|
||||
|
||||
CSI_fg=$'\e[38;2;'
|
||||
CSI_bg=$'\e[48;2;'
|
||||
esc_reset=$'\e[0m'
|
||||
|
||||
esc=(
|
||||
"0;0;0m" # black
|
||||
"0;0;168m" # blue
|
||||
"0;168;0m" # green
|
||||
"0;168;168m" # cyan
|
||||
"168;0;0m" # red
|
||||
"168;0;168m" # magenta
|
||||
"168;84;0m" # brown
|
||||
"168;168;168m" # light-gray
|
||||
"84;84;84m" # dark-gray
|
||||
"84;84;254m" # light-blue
|
||||
"84;254;84m" # light-green
|
||||
"84;254;254m" # light-cyan
|
||||
"254;84;84m" # light-red
|
||||
"254;84;254m" # light-magenta
|
||||
"254;254;84m" # yellow
|
||||
"254;254;254m" # white
|
||||
)
|
||||
|
||||
# make black opaque for truecolor terminal emulators:
|
||||
[[ $COLORTERM = "truecolor" ]] && esc[0]="1;1;1m"
|
||||
|
||||
cname=(
|
||||
"black"
|
||||
"blue"
|
||||
"green"
|
||||
"cyan"
|
||||
"red"
|
||||
"magenta"
|
||||
"brown"
|
||||
"light-gray"
|
||||
"dark-gray"
|
||||
"light-blue"
|
||||
"light-green"
|
||||
"light-cyan"
|
||||
"light-red"
|
||||
"light-magenta"
|
||||
"yellow"
|
||||
"white"
|
||||
)
|
||||
|
||||
val=(0 9 1 11) #normal bg, normal fg, highlighted bg, highlighted fg
|
||||
selected=0;
|
||||
|
||||
print_menu() {
|
||||
gb=$CSI_bg${esc[0]}$CSI_fg${esc[7]}
|
||||
no=$CSI_bg${esc[${val[0]}]}$CSI_fg${esc[${val[1]}]}
|
||||
hl=$CSI_bg${esc[${val[2]}]}$CSI_fg${esc[${val[3]}]}
|
||||
|
||||
cat \
|
||||
<< EOF
|
||||
$gb Colour Chooser for GRUB - PREVIEW $esc_reset
|
||||
$gb $no┌────────────────────────────────────────────┐$gb $esc_reset
|
||||
$gb $no│ Normal option │$gb $esc_reset
|
||||
$gb $no│ Normal option │$gb $esc_reset
|
||||
$gb $no│$hl Highlighted option $no│$gb $esc_reset
|
||||
$gb $no│ Normal option │$gb $esc_reset
|
||||
$gb $no│ │$gb $esc_reset
|
||||
$gb $no│ │$gb $esc_reset
|
||||
$gb $no│ │$gb $esc_reset
|
||||
$gb $no└────────────────────────────────────────────┘$gb $esc_reset
|
||||
$gb Use the arrow keys to change the values below. $esc_reset
|
||||
$gb Press ENTER when done. $esc_reset
|
||||
$gb $esc_reset
|
||||
EOF
|
||||
|
||||
local SO
|
||||
local SC
|
||||
SO[$selected]='>'
|
||||
SC[$selected]='<'
|
||||
|
||||
printf "%s Normal background: %-2s%-14s%s%2s %s\n" \
|
||||
"$gb" "${SO[0]}" "${cname[${val[0]}]}" "$CSI_fg${esc[${val[0]}]}██$gb" \
|
||||
"${SC[0]}" "$esc_reset"
|
||||
printf "%s Normal foreground: %-2s%-14s%s%2s %s\n" \
|
||||
"$gb" "${SO[1]}" "${cname[${val[1]}]}" "$CSI_fg${esc[${val[1]}]}██$gb" \
|
||||
"${SC[1]}" "$esc_reset"
|
||||
printf "%s Highlighted background: %-2s%-14s%s%2s %s\n" \
|
||||
"$gb" "${SO[2]}" "${cname[${val[2]}]}" "$CSI_fg${esc[${val[2]}]}██$gb" \
|
||||
"${SC[2]}" "$esc_reset"
|
||||
printf "%s Highlighted foreground: %-2s%-14s%s%2s %s\n" \
|
||||
"$gb" "${SO[3]}" "${cname[${val[3]}]}" "$CSI_fg${esc[${val[3]}]}██$gb" \
|
||||
"${SC[3]}" "$esc_reset"
|
||||
}
|
||||
|
||||
move_cursor_top() {
|
||||
printf "\e[17A\r"
|
||||
}
|
||||
|
||||
|
||||
while true; do
|
||||
print_menu
|
||||
# wait for input
|
||||
read -rsn1 key
|
||||
[[ $key = $'' ]] && break
|
||||
[[ $key = $'\u1b' ]] && {
|
||||
read -rsn2 key
|
||||
}
|
||||
[[ -n $key ]] && {
|
||||
case "$key" in
|
||||
'[D'|h ) val[$selected]=$(((val[selected]+15)%16)) ;;
|
||||
'[B'|j ) selected=$((selected >= 3 ? 3 : selected+1)) ;;
|
||||
'[A'|k ) selected=$((selected <= 0 ? 0 : selected-1)) ;;
|
||||
'[C'|l ) val[$selected]=$(((val[selected]+1) % 16)) ;;
|
||||
esac
|
||||
}
|
||||
move_cursor_top
|
||||
done
|
||||
|
||||
move_cursor_top
|
||||
selected=5
|
||||
print_menu
|
||||
|
||||
timestamp="$(date +'%Y-%m-%d %H:%M')"
|
||||
|
||||
sedscript="/^GRUB_COLOR_NORMAL=/i \# commented out by grub-colour-chooser, $timestamp:
|
||||
s|^GRUB_COLOR_NORMAL=|\#GRUB_COLOR_NORMAL=|
|
||||
/^GRUB_COLOR_HIGHLIGHT=/i \# commented out by grub-colour-chooser, $timestamp:
|
||||
s|^GRUB_COLOR_HIGHLIGHT=|\#GRUB_COLOR_HIGHLIGHT=|
|
||||
/^GRUB_THEME=/i \# commented out by grub-colour-chooser, $timestamp:
|
||||
s|^GRUB_THEME=|\#GRUB_THEME=|"
|
||||
|
||||
sed "$sedscript" "$etcdefaultgrubfile" > "$tmpfile"
|
||||
printf "\n#Added by grub-colour-chooser, %s:\nGRUB_COLOR_NORMAL=\"%s\"\nGRUB_COLOR_HIGHLIGHT=\"%s\"\n" \
|
||||
"$timestamp" \
|
||||
"${cname[${val[1]}]}/${cname[${val[0]}]}" \
|
||||
"${cname[${val[3]}]}/${cname[${val[2]}]}" >> "$tmpfile"
|
||||
|
||||
printf "\nThe following changes to %s are proposed:\n\n" "$etcdefaultgrubfile"
|
||||
diff --color=auto "$etcdefaultgrubfile" "$tmpfile" && true
|
||||
|
||||
printf '\e[?25h\n' # unhide cursor and print new line
|
||||
stty echo
|
||||
read -p "Apply these changes and run grub-mkconfig [y/N]? " response
|
||||
if [[ $response =~ ^(yes|y|Y|Yes)$ ]]; then
|
||||
sudo cp -- "$tmpfile" "$etcdefaultgrubfile" || exit
|
||||
sudo grub-mkconfig -o "$grubconffile"
|
||||
fi
|
||||
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
import dbus
|
||||
import argparse
|
||||
import glob
|
||||
import random
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
HOME = str(Path.home())
|
||||
SCREEN_LOCK_CONFIG = HOME+"/.config/kscreenlockerrc"
|
||||
def setwallpaper(filepath, plugin='org.kde.image'):
|
||||
jscript = """
|
||||
var allDesktops = desktops();
|
||||
print (allDesktops);
|
||||
for (i=0;i<allDesktops.length;i++) {
|
||||
d = allDesktops[i];
|
||||
d.wallpaperPlugin = "%s";
|
||||
d.currentConfigGroup = Array("Wallpaper", "%s", "General");
|
||||
d.writeConfig("Image", "file://%s")
|
||||
}
|
||||
"""
|
||||
bus = dbus.SessionBus()
|
||||
plasma = dbus.Interface(bus.get_object(
|
||||
'org.kde.plasmashell', '/PlasmaShell'), dbus_interface='org.kde.PlasmaShell')
|
||||
plasma.evaluateScript(jscript % (plugin, plugin, filepath))
|
||||
|
||||
def set_lockscreen_wallpaper(filepath,plugin='org.kde.image'):
|
||||
if os.path.exists(SCREEN_LOCK_CONFIG):
|
||||
new_data=[]
|
||||
with open(SCREEN_LOCK_CONFIG, "r") as kscreenlockerrc:
|
||||
new_data = kscreenlockerrc.readlines()
|
||||
is_wallpaper_section=False
|
||||
for num,line in enumerate(new_data,1):
|
||||
if "[Greeter][Wallpaper]["+plugin+"][General]" in line:
|
||||
is_wallpaper_section = True
|
||||
if "Image=" in line and is_wallpaper_section:
|
||||
new_data[num-1] = "Image="+filepath+"\n"
|
||||
break
|
||||
|
||||
with open(SCREEN_LOCK_CONFIG, "w") as kscreenlockerrc:
|
||||
kscreenlockerrc.writelines(new_data)
|
||||
|
||||
def is_locked():
|
||||
is_locked=subprocess.check_output("qdbus org.kde.screensaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive",shell=True,universal_newlines=True).strip()
|
||||
if is_locked == "true":
|
||||
is_locked = True
|
||||
else:
|
||||
is_locked = False
|
||||
return is_locked
|
||||
|
||||
def get_walls_from_folder(directory):
|
||||
return glob.glob(directory+'/*')
|
||||
|
||||
|
||||
def wallpaper_slideshow(wallapapers, plugin, timer, lock_screen):
|
||||
if timer > 0:
|
||||
wallpaper_count = len(wallapapers)
|
||||
delta_s = timer
|
||||
s = int(delta_s % 60)
|
||||
m = int((delta_s / 60) % 60)
|
||||
h = int((delta_s / 3600) % 3600)
|
||||
if h > 0:
|
||||
timer_show = f"{h}h {m}m {s}s"
|
||||
elif m > 0:
|
||||
timer_show = f"{m}m {s}s"
|
||||
elif s > 0:
|
||||
timer_show = f"{s}s"
|
||||
print(
|
||||
f"Looping through {wallpaper_count} wallpapers every {timer_show}")
|
||||
while True:
|
||||
if is_locked() != True:
|
||||
random_int = random.randint(0, wallpaper_count-1)
|
||||
wallpaper_now = wallapapers[random_int]
|
||||
setwallpaper(wallpaper_now, plugin)
|
||||
if lock_screen == True:
|
||||
set_lockscreen_wallpaper(wallpaper_now, plugin)
|
||||
time.sleep(timer)
|
||||
else:
|
||||
raise ValueError('Invalid --timer value')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='KDE Wallpaper setter')
|
||||
parser.add_argument('--file','-f', help='Wallpaper file name', default=None)
|
||||
parser.add_argument(
|
||||
'--plugin', '-p', help='Wallpaper plugin (default is org.kde.image)', default='org.kde.image')
|
||||
parser.add_argument('--dir', '-d', type=str,
|
||||
help='Absolute path of folder containging your wallpapers for slideshow', default=None)
|
||||
parser.add_argument('--timer', '-t', type=int,
|
||||
help='Time in seconds between wallpapers', default=900)
|
||||
parser.add_argument('--lock-screen', '-l', action="store_true",
|
||||
help="Set lock screen wallpaper")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.file != None:
|
||||
setwallpaper(filepath=args.file, plugin=args.plugin)
|
||||
if args.lock_screen == True:
|
||||
set_lockscreen_wallpaper(filepath=args.file, plugin=args.plugin)
|
||||
|
||||
elif args.dir != None:
|
||||
wallpapers = get_walls_from_folder(args.dir)
|
||||
|
||||
wallpaper_slideshow(wallapapers=wallpapers,
|
||||
plugin=args.plugin, timer=args.timer,lock_screen=args.lock_screen)
|
||||
else:
|
||||
print("Need help? use -h or --help")
|
||||
Executable
+218
@@ -0,0 +1,218 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Simple service manager for pacman cache cleaner.
|
||||
#
|
||||
# Requires packages:
|
||||
# pacman-contrib (for paccache)
|
||||
# yad (for yad)
|
||||
# polkit (for pkexec)
|
||||
#
|
||||
|
||||
source /usr/share/endeavouros/scripts/eos-script-lib-yad || exit 1
|
||||
|
||||
export -f eos_yad
|
||||
|
||||
DIE() {
|
||||
local msg="$1"
|
||||
shift
|
||||
if false ; then
|
||||
echo "Error: $msg" | eos_yad --text-info --image=error --title="$progname error" \
|
||||
--wrap --width=500 --height=300 --button=yad-quit:1 "$@"
|
||||
else
|
||||
eos_yad --form --image=error --title="$progname error" --text="Error: $msg" --button=yad-quit:1 --scroll "$@"
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
GetCurrentValues() {
|
||||
local t="$timer"
|
||||
local s="$service"
|
||||
|
||||
if [ ! -r $s ] ; then
|
||||
# service is only under /usr/lib/... so get current values from there
|
||||
t="$dir2/$pt"
|
||||
s="$dir2/paccache.service"
|
||||
|
||||
local why="Is pacman-contrib installed?"
|
||||
test -r $t || DIE "sorry, $t does not exist. $why"
|
||||
test -r $s || DIE "sorry, $s does not exist. $why"
|
||||
fi
|
||||
|
||||
current_period="$( grep "^OnCalendar=" $t | cut -d '=' -f 2)"
|
||||
current_keepcount="$(grep "^ExecStart=" $s | awk '{print $NF}')"
|
||||
current_delete_uninstalled=FALSE
|
||||
|
||||
# ad hoc check for the 'keepcount' value
|
||||
case "$current_keepcount" in
|
||||
-r) current_keepcount=3 ;; # original value
|
||||
-rk*)
|
||||
[ "$(echo "${current_keepcount:3}" | sed 's|[0-9]||g')" = "" ] || {
|
||||
local line=$(grep "^ExecStart=" $s)
|
||||
DIE "invalid value for option <tt>-k</tt> in file\n<tt>$s</tt>\nline:\n\n<tt>${line::70}</tt>"
|
||||
}
|
||||
current_keepcount="${current_keepcount:3}" # value after using this app
|
||||
[ -z "$current_keepcount" ] && DIE "file '$s': paccache option '-k' requires a value."
|
||||
;;
|
||||
*)
|
||||
local line=$(grep "^ExecStart=" $s)
|
||||
DIE "invalid line in file\n<tt>$s</tt>\nline:\n\n<tt>${line::70}</tt>"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
Usage: $progname [options]
|
||||
|
||||
Options:
|
||||
--defaults Enable manager with default values (run $period, keep latest $keepcount).
|
||||
-v, --verbose Increase verbosity (= see more terminal output).
|
||||
-h, --help This help.
|
||||
EOF
|
||||
[ -n "$1" ] && exit "$1"
|
||||
}
|
||||
|
||||
AddCommand() {
|
||||
local command="$1"
|
||||
|
||||
cmds+=" ; $command"
|
||||
if [ "$verbose" = "yes" ] ; then
|
||||
echo "$command" >> $vfile
|
||||
fi
|
||||
}
|
||||
|
||||
_paccache_cleaner_manager()
|
||||
{
|
||||
local progname=paccache-service-manager
|
||||
local dir=/etc/systemd/system
|
||||
local dir2=/usr/lib/systemd/system # current values may be only here...
|
||||
local service=$dir/paccache.service
|
||||
local timer=$dir/paccache.timer
|
||||
local current_period
|
||||
local current_keepcount
|
||||
local current_delete_uninstalled
|
||||
local pt="paccache.timer"
|
||||
local cmd_yad
|
||||
local cmds=":" cmds2=() cmd_period cmd_ruk=""
|
||||
local xx
|
||||
local period_vals=""
|
||||
local txt
|
||||
local image=drive-harddisk # disk-utility
|
||||
local result=""
|
||||
local field_nr=1
|
||||
local indent="<tt> </tt>"
|
||||
local du="$(LANG=C /usr/bin/du --si -s /var/cache/pacman/pkg | /usr/bin/awk '{print $1}' | sed 's|\([KMGT]\)$| \1B|')"
|
||||
local df="$(LANG=C /usr/bin/df --si | /usr/bin/grep -w / | /usr/bin/awk '{print $4}' | sed 's|\([KMGT]\)$| \1B|')"
|
||||
local options=""
|
||||
local defaults=no
|
||||
local period=weekly keepcount=2 delete_uninstalled=FALSE
|
||||
local first_time=no
|
||||
local verbose=no
|
||||
local vfile="" # temporary file for showing all commands in verbose mode
|
||||
local keepcount_max=100
|
||||
|
||||
if [ ! -r $service ] ; then
|
||||
first_time=yes
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
-v | --verbose) options+=" -v"
|
||||
options="${options# }" # drop leading space
|
||||
verbose=yes
|
||||
vfile="$(mktemp)"
|
||||
;;
|
||||
-h | --help) Usage 0
|
||||
;;
|
||||
--defaults) defaults=yes
|
||||
;;
|
||||
esac
|
||||
|
||||
GetCurrentValues
|
||||
|
||||
if [ "$defaults" = "no" ] ; then
|
||||
txt="<b>Modifies the service that cleans up pacman cache periodically.\n"
|
||||
txt+="Below you'll see settings and their current values.\n\n"
|
||||
txt+="Current status:\n"
|
||||
txt+="${indent}Package cache usage: $du\n"
|
||||
txt+="${indent}Free space on disk: $df</b>\n"
|
||||
txt+="\n"
|
||||
|
||||
# List possible period values, and set the default
|
||||
for xx in daily weekly monthly ; do
|
||||
test -n "$period_vals" && period_vals+="!" # separator
|
||||
test "$xx" = "$current_period" && period_vals+="^" # default
|
||||
period_vals+="$xx"
|
||||
done
|
||||
|
||||
cmd_yad=(
|
||||
eos_yad --form --width=500 --image=$image
|
||||
--title='Pacman cache cleaner service manager'
|
||||
--text="$txt"
|
||||
--field='Cleaning period':CB "$period_vals"
|
||||
--field='Number of package versions to keep':NUM "$current_keepcount"
|
||||
--field='Remove uninstalled but still cached packages now':CHK "$current_delete_uninstalled"
|
||||
)
|
||||
|
||||
result="$("${cmd_yad[@]}" 2>/dev/null)"
|
||||
[ -n "$result" ] || return # package kde-gtk-config should remove possible gtk related yad warnings...
|
||||
|
||||
# New values
|
||||
period="$( echo "$result" | cut -d '|' -f $field_nr)" ; ((++field_nr))
|
||||
keepcount="$( echo "$result" | cut -d '|' -f $field_nr)" ; ((++field_nr))
|
||||
delete_uninstalled="$(echo "$result" | cut -d '|' -f $field_nr)" ; ((++field_nr))
|
||||
|
||||
# ad hoc value checks
|
||||
[ "$(echo "$keepcount" | sed 's|[0-9]||g')" = "" ] || DIE "sorry, keep count value '$keepcount' is not a number"
|
||||
[ $keepcount -le $keepcount_max ] || DIE "sorry, keep count value '$keepcount' is more than $keepcount_max and not supported"
|
||||
|
||||
case "$period" in
|
||||
daily | weekly | monthly) ;;
|
||||
*) DIE "sorry, cleaning period '$period' is unsupported" ;;
|
||||
esac
|
||||
|
||||
case "$delete_uninstalled" in
|
||||
TRUE | FALSE) ;;
|
||||
*) DIE "sorry, value '$delete_uninstalled' for removing uninstalled packages is unsupported" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Build the final paccache command list.
|
||||
|
||||
# Clean up cache now and periodically
|
||||
|
||||
if [ "$delete_uninstalled" = "TRUE" ] ; then
|
||||
cmd_ruk="paccache $options -ruk0"
|
||||
fi
|
||||
|
||||
if [ "$keepcount $period $delete_uninstalled" != "$current_keepcount $current_period $current_delete_uninstalled" ] || [ "$first_time" = "yes" ] ; then
|
||||
cmd_period="paccache $options -rk$keepcount"
|
||||
|
||||
if [ ! -r $service ] ; then
|
||||
AddCommand "cp $dir2/$pt $timer"
|
||||
AddCommand "cp $dir2/paccache.service $service"
|
||||
fi
|
||||
# Allow ExecStart line with both /usr/bin/paccache or just paccache.
|
||||
AddCommand "sed -i $service -e 's|^ExecStart=paccache .*$|ExecStart=$cmd_period|' -e 's|^ExecStart=/usr/bin/paccache .*$|ExecStart=$cmd_period|'"
|
||||
AddCommand "sed -i $timer -e 's|^OnCalendar=.*$|OnCalendar=$period|'"
|
||||
AddCommand "systemctl enable --now $pt"
|
||||
AddCommand "systemctl daemon-reload"
|
||||
fi
|
||||
if [ -n "$cmd_ruk" ] ; then
|
||||
AddCommand "$cmd_ruk"
|
||||
fi
|
||||
|
||||
# Execute the command list.
|
||||
|
||||
if [ "$cmds" != ":" ] ; then
|
||||
if [ "$verbose" = "yes" ] ; then
|
||||
pkexec bash -c "cat '$vfile' ; $cmds"
|
||||
rm -f "$vfile"
|
||||
else
|
||||
pkexec bash -c "$cmds"
|
||||
fi
|
||||
else
|
||||
echo "No change to settings."
|
||||
fi
|
||||
}
|
||||
|
||||
_paccache_cleaner_manager "$@"
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Show parts of a given package file name.
|
||||
|
||||
DIE() {
|
||||
echo "$progname: error: $1" >&2
|
||||
Usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
|
||||
Usage:
|
||||
$progname -h|--help
|
||||
Shows this help.
|
||||
|
||||
$progname [--real] "parts" "package-file-name"
|
||||
--real
|
||||
Give output as in real parts of the package name.
|
||||
parts
|
||||
String of upper case letters consisting of: N V R A C E.
|
||||
N = pkgname
|
||||
V = pkgver
|
||||
R = pkgrel
|
||||
A = arch
|
||||
C = compressor
|
||||
E = epoch
|
||||
These letters specify what the output will contain.
|
||||
The output values are separated by the pipe '|' character.
|
||||
package-file-name
|
||||
Name of a package file.
|
||||
|
||||
Examples:
|
||||
$ $progname NEVRAC foo-bar-2:22.04.23-1-any.pkg.tar.zst
|
||||
foo-bar|2|22.04.23|1|any|zst
|
||||
|
||||
$ $progname --real NEVRAC foo-bar-2:22.04.23-1-any.pkg.tar.zst
|
||||
foo-bar-2:22.04.23-1-any.zst
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
SeparateParts() {
|
||||
local pkg="$1"
|
||||
|
||||
local all=$(echo "$pkg" | sed -E 's/([a-zA-Z0-9@_+][a-zA-Z0-9@._+-]+)-([0-9:]*[^:/\-\ \t]+)-([0-9.]+)-([a-z0-9_]+)\.pkg\.tar\.([a-z0-9]+)$/\1 \2 \3 \4 \5/')
|
||||
all=($(echo $all))
|
||||
|
||||
local N=${all[0]}
|
||||
local V=${all[1]} # may include epoch!
|
||||
local R=${all[2]}
|
||||
local A=${all[3]}
|
||||
local C=${all[4]}
|
||||
local E="0" # default (=unspecified) epoch is 0
|
||||
|
||||
local sep=""
|
||||
local result=""
|
||||
local ix item
|
||||
|
||||
case "$real_out" in
|
||||
yes) sep="-" ;; # for most components
|
||||
no) sep="|" ;; # for all
|
||||
esac
|
||||
|
||||
if [ "${V%:*}" != "$V" ] ; then
|
||||
E="${V%:*}"
|
||||
V="${V#*:}"
|
||||
fi
|
||||
|
||||
for ((ix=0; ix < ${#parts}; ix++)) ; do
|
||||
item="${parts:$ix:1}"
|
||||
case "$item" in
|
||||
N) result+="$N$sep" ;;
|
||||
V) result+="$V$sep" ;;
|
||||
R) result+="$R$sep" ;;
|
||||
A) result+="$A$sep" ;;
|
||||
C) result+="$C$sep" ;;
|
||||
E) case "$real_out" in
|
||||
yes) [ $E -ne 0 ] && result+="$E:" ;; # don't show epoch if it is zero
|
||||
no) result+="$E$sep" ;;
|
||||
esac
|
||||
;;
|
||||
*) DIE "given parameter '$parts' includes an unsupported value '$item'." ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$result" ] || DIE "no result!"
|
||||
|
||||
result="${result:: -1}"
|
||||
[ -n "$result" ] || DIE "result is empty!"
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
Main() {
|
||||
local real_out=no
|
||||
local parts
|
||||
local pkg
|
||||
local progname="$(basename "$0")"
|
||||
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
Usage
|
||||
return 0
|
||||
;;
|
||||
--real)
|
||||
real_out=yes
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
Usage
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
parts="$1"
|
||||
pkg="$2"
|
||||
|
||||
if [ -n "$pkg" ] ; then
|
||||
SeparateParts "$pkg"
|
||||
else
|
||||
while read pkg ; do
|
||||
SeparateParts "$pkg"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Show (a short piece of) information related to current location.
|
||||
# Use a keyword to specify what info to show.
|
||||
|
||||
DIE() {
|
||||
echo "==> $progname: error: $1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
Options() {
|
||||
local opts
|
||||
local lopts="help,timeout:,tolower,url:"
|
||||
local sopts="ht:lu:"
|
||||
|
||||
opts="$(/usr/bin/getopt -o=$sopts --longoptions $lopts --name "$progname" -- "$@")" || {
|
||||
Options -h
|
||||
return 1
|
||||
}
|
||||
|
||||
eval set -- "$opts"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-t | --timeout) timeout="$2" ; shift ;;
|
||||
-l | --tolower) tolower=yes ;;
|
||||
-u | --url) infourl="$2" ; shift ;;
|
||||
-h | --help)
|
||||
cat <<EOF >&2
|
||||
$progname - show info about your current location
|
||||
|
||||
Usage: $progname [options] [location-item]
|
||||
|
||||
Location-item: one of
|
||||
${items[*]}
|
||||
Location-item defaults to showing all available info.
|
||||
|
||||
Options:
|
||||
-h, --help This help.
|
||||
-l, --tolower Convert letters to lower case on the output.
|
||||
-t, --timeout Max number of seconds to wait for a response from
|
||||
$infourl (default: $timeout_default).
|
||||
-u, --url The URL used for getting the location information.
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
item="$1"
|
||||
|
||||
local it
|
||||
for it in "${items[@]}" ; do
|
||||
[ "$item" = "$it" ] && break
|
||||
done
|
||||
|
||||
[ "$item" = "$it" ] || DIE "item name must be one of: ${items[*]}"
|
||||
[ -n "$timeout" ] || DIE "given timeout value cannot be empty"
|
||||
}
|
||||
|
||||
Main() {
|
||||
local progname="$(basename "$0")"
|
||||
|
||||
# default values
|
||||
local timeout_default=30
|
||||
local timeout=$timeout_default
|
||||
local tolower=no
|
||||
local item=""
|
||||
|
||||
# supported values
|
||||
local items=(city country hostname ip loc org postal region timezone "") # "" means: all
|
||||
|
||||
# info source
|
||||
local infourl="$EOS_LOCATION_PROVIDER_URL"
|
||||
[ -n "$infourl" ] || infourl="https://ipinfo.io"
|
||||
|
||||
Options "$@"
|
||||
|
||||
case "$infourl" in
|
||||
https://ipinfo.io) ;;
|
||||
https://ipapi.co)
|
||||
case "$item" in
|
||||
hostname | loc | "")
|
||||
DIE "sorry, item '$item' is not supported for url $infourl"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*) DIE "'$infourl' is not supported. See /etc/eos-script-lib-yad.conf for supported URLs" ;;
|
||||
esac
|
||||
|
||||
# show the wanted location info
|
||||
local output="$(LANG=C curl -Lsm $timeout $infourl/$item)"
|
||||
if [ "$tolower" = "yes" ] ; then
|
||||
output=$(echo "$output" | tr '[:upper:]' '[:lower:]')
|
||||
fi
|
||||
echo "$output"
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Helper for the 'su -c' command
|
||||
# (understands spaces in command parameters).
|
||||
|
||||
Usage() {
|
||||
cat <<EOF
|
||||
Usage: $progname [-p] command-with-parameters
|
||||
-p Meant to be used by the Welcome app only.
|
||||
EOF
|
||||
#echo "Usage: $progname [-p] command-with-parameters" >&2
|
||||
}
|
||||
|
||||
DIE() {
|
||||
echo "$progname: Error: $1" >&2
|
||||
Usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
Main() {
|
||||
local progname="su-c_wrapper"
|
||||
local command=()
|
||||
local xx result=0
|
||||
local subresultfile="$(mktemp -u $HOME/$progname.$(date +%s%N).XXXXX)"
|
||||
local owner="$LOGNAME:users"
|
||||
local subresult=0
|
||||
local prompt="Root "
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-p) prompt+="Password: " ; shift ;;
|
||||
"") DIE "command missing" ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# test -z "$1" && DIE "command missing"
|
||||
|
||||
# command and parameters containing spaces: surround each with single quotes
|
||||
for xx in "$@" ; do
|
||||
command+=("'$xx'")
|
||||
done
|
||||
|
||||
# run max 3 times
|
||||
for xx in {2..0} ; do
|
||||
printf "$prompt"
|
||||
LANG=C /usr/bin/su -c "${command[*]} ; echo $? > '$subresultfile' ; chown $owner '$subresultfile'"
|
||||
|
||||
result=$?
|
||||
if [ -r "$subresultfile" ] ; then
|
||||
subresult="$(cat "$subresultfile")"
|
||||
rm -f "$subresultfile"
|
||||
fi
|
||||
|
||||
case "$result" in
|
||||
0) # OK
|
||||
break ;;
|
||||
127|126) # command is erroneous or can't be executed
|
||||
break ;;
|
||||
1) # wrong password or subcommand failure
|
||||
case $subresult in
|
||||
0) ;; # wrong password
|
||||
*) break ;; # subcommand failure
|
||||
esac
|
||||
;;
|
||||
*) ;; # signal killed command
|
||||
esac
|
||||
if [ $xx -ne 0 ] ; then
|
||||
echo "Sorry, try again ($xx)." >&2
|
||||
else
|
||||
echo "Fail." >&2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Main "$@"
|
||||
Reference in New Issue
Block a user