Simple maintenance improvements (#1370)
* rofi moved to libera.chat * unify some theme headers and whitespace * consistently use the same hashbang for bash * improve obsolete way of testing equality see https://github.com/koalaman/shellcheck/wiki/SC2268 for explanation * use consistent function definitions in bash scripts * remove duplicated author and fix whitespace * quote all variables in scripts fixes many warnings identified through shellcheck * fix whitespace in scripts * fix whitespace in non-source files * fix spelling in non-source files * fix whitespace and indentation in source files * fix spelling in source files
This commit is contained in:
@@ -6,18 +6,18 @@ GIT=$(which git)
|
||||
|
||||
if [ -d "${DIR}/.git/" ] && [ -n "${GIT}" ]
|
||||
then
|
||||
echo -n "#define GIT_VERSION \"" > ${FILE}.tmp
|
||||
echo -n "#define GIT_VERSION \"" > "${FILE}.tmp"
|
||||
BRTG="$(${GIT} describe --tags --always --all | sed -e 's:heads/::')"
|
||||
REV="$(${GIT} describe --tags --always --dirty| sed -e 's:-g\([a-f0-9]\{7\}\):-git-\1:g')"
|
||||
echo -n "${REV} (${BRTG})" >> ${FILE}.tmp
|
||||
echo "\"" >> ${FILE}.tmp
|
||||
echo -n "${REV} (${BRTG})" >> "${FILE}.tmp"
|
||||
echo "\"" >> "${FILE}.tmp"
|
||||
else
|
||||
echo "#undef GIT_VERSION" > ${FILE}.tmp
|
||||
echo "#undef GIT_VERSION" > "${FILE}.tmp"
|
||||
fi
|
||||
|
||||
if [ ! -f ${FILE} ] || ! diff ${FILE}.tmp ${FILE} > /dev/null
|
||||
if [ ! -f "${FILE}" ] || ! diff "${FILE}.tmp" "${FILE}" >/dev/null
|
||||
then
|
||||
mv ${FILE}.tmp ${FILE}
|
||||
mv "${FILE}.tmp" "${FILE}"
|
||||
else
|
||||
rm ${FILE}.tmp
|
||||
rm "${FILE}.tmp"
|
||||
fi
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
|
||||
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
|
||||
# This converts from old style theme (< 1.4) to new style theme (>= 1.4)
|
||||
#
|
||||
function update_color ()
|
||||
update_color()
|
||||
{
|
||||
var=${1}
|
||||
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||
@@ -12,11 +12,11 @@ function update_color ()
|
||||
then
|
||||
echo "#${var:5}"
|
||||
else
|
||||
echo ${var}
|
||||
echo "${var}"
|
||||
fi
|
||||
}
|
||||
|
||||
function parse_window_color ()
|
||||
parse_window_color()
|
||||
{
|
||||
OLDIFS=${IFS}
|
||||
IFS=","
|
||||
@@ -37,7 +37,7 @@ function parse_window_color ()
|
||||
IFS=${OLDIFS}
|
||||
}
|
||||
|
||||
function parse_color ()
|
||||
parse_color()
|
||||
{
|
||||
state=$1
|
||||
OLDIFS=${IFS}
|
||||
@@ -62,13 +62,13 @@ while read LINE
|
||||
do
|
||||
if [[ ${LINE} =~ ^rofi\.color-normal: ]]
|
||||
then
|
||||
parse_color "normal" "${LINE:18}"
|
||||
parse_color "normal" "${LINE:18}"
|
||||
elif [[ ${LINE} =~ ^rofi\.color-urgent: ]]
|
||||
then
|
||||
parse_color "urgent" "${LINE:18}"
|
||||
parse_color "urgent" "${LINE:18}"
|
||||
elif [[ ${LINE} =~ ^rofi\.color-active: ]]
|
||||
then
|
||||
parse_color "active" "${LINE:18}"
|
||||
parse_color "active" "${LINE:18}"
|
||||
elif [[ ${LINE} =~ ^rofi\.color-window: ]]
|
||||
then
|
||||
parse_window_color "${LINE:18}"
|
||||
|
@@ -13,14 +13,14 @@ shift
|
||||
OUTPUT_PNG=$1
|
||||
shift
|
||||
|
||||
XVFB=$(which Xvfb 2> /dev/null)
|
||||
XDOTOOL=$(which xdotool 2> /dev/null)
|
||||
ROFI=$(which rofi 2> /dev/null)
|
||||
SCROT=$(which scrot 2> /dev/null)
|
||||
FEH=$(which feh 2> /dev/null)
|
||||
COMPTON=$(which compton 2> /dev/null)
|
||||
XVFB=$(which Xvfb 2>/dev/null)
|
||||
XDOTOOL=$(which xdotool 2>/dev/null)
|
||||
ROFI=$(which rofi 2>/dev/null)
|
||||
SCROT=$(which scrot 2>/dev/null)
|
||||
FEH=$(which feh 2>/dev/null)
|
||||
COMPTON=$(which compton 2>/dev/null)
|
||||
|
||||
function check_tool()
|
||||
check_tool()
|
||||
{
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
@@ -30,26 +30,26 @@ function check_tool()
|
||||
}
|
||||
|
||||
XPID=
|
||||
function create_fake_x ( )
|
||||
create_fake_x()
|
||||
{
|
||||
export DISPLAY=":$1"
|
||||
echo "Starting fake X: ${DISPLAY}"
|
||||
${XVFB} ${DISPLAY} -screen 0 1024x600x24&
|
||||
${XVFB} "${DISPLAY}" -screen 0 1024x600x24 &
|
||||
XPID=$!
|
||||
sleep 1
|
||||
}
|
||||
|
||||
function destroy_fake_x ( )
|
||||
destroy_fake_x()
|
||||
{
|
||||
if [ -n "${XPID}" ]
|
||||
then
|
||||
echo "Stopping fake X: ${XPID}"
|
||||
kill ${XPID}
|
||||
wait ${XPID}
|
||||
kill "${XPID}"
|
||||
wait "${XPID}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate()
|
||||
generate()
|
||||
{
|
||||
echo "Normal"
|
||||
echo "Alternative"
|
||||
@@ -81,16 +81,16 @@ ROFI_OPTIONS="-selected-row 6 -u 2,3 -a 4,5 -location 0 -width 100 -lines 7 -col
|
||||
export DISPLAY=${VDISPLAY}
|
||||
|
||||
# Create fake X11
|
||||
create_fake_x ${VDISPLAY}
|
||||
create_fake_x "${VDISPLAY}"
|
||||
sleep 1
|
||||
fluxbox &
|
||||
sleep 1;
|
||||
compton -b
|
||||
sleep 1
|
||||
compton -b
|
||||
feh --bg-center background.jpg
|
||||
(generate | ${ROFI} -no-config -theme "${THEME_FILE}" -dmenu ${ROFI_OPTIONS} > /dev/null )&
|
||||
(generate | ${ROFI} -no-config -theme "${THEME_FILE}" -dmenu ${ROFI_OPTIONS} >/dev/null )&
|
||||
sleep 1
|
||||
#${XDOTOOL} key Alt+S
|
||||
scrot ${OUTPUT_PNG}
|
||||
scrot "${OUTPUT_PNG}"
|
||||
${XDOTOOL} key Return
|
||||
sleep 2
|
||||
destroy_fake_x
|
||||
|
@@ -14,12 +14,12 @@ shift
|
||||
OUTPUT_PNG=$1
|
||||
shift
|
||||
|
||||
XVFB=$(which Xvfb 2> /dev/null)
|
||||
XDOTOOL=$(which xdotool 2> /dev/null)
|
||||
XRDB=$(which xrdb 2> /dev/null)
|
||||
ROFI=$(which rofi 2> /dev/null)
|
||||
XVFB=$(which Xvfb 2>/dev/null)
|
||||
XDOTOOL=$(which xdotool 2>/dev/null)
|
||||
XRDB=$(which xrdb 2>/dev/null)
|
||||
ROFI=$(which rofi 2>/dev/null)
|
||||
|
||||
function check_tool()
|
||||
check_tool()
|
||||
{
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
@@ -29,26 +29,26 @@ function check_tool()
|
||||
}
|
||||
|
||||
XPID=
|
||||
function create_fake_x ( )
|
||||
create_fake_x()
|
||||
{
|
||||
export DISPLAY=":$1"
|
||||
echo "Starting fake X: ${DISPLAY}"
|
||||
${XVFB} ${DISPLAY} -screen 0 800x600x24 &
|
||||
${XVFB} "${DISPLAY}" -screen 0 800x600x24 &
|
||||
XPID=$!
|
||||
sleep 1
|
||||
}
|
||||
|
||||
function destroy_fake_x ( )
|
||||
destroy_fake_x()
|
||||
{
|
||||
if [ -n "${XPID}" ]
|
||||
then
|
||||
echo "Stopping fake X: ${XPID}"
|
||||
kill ${XPID}
|
||||
wait ${XPID}
|
||||
kill "${XPID}"
|
||||
wait "${XPID}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate()
|
||||
generate()
|
||||
{
|
||||
echo "Normal"
|
||||
echo "Alternative"
|
||||
@@ -84,13 +84,13 @@ then
|
||||
fi
|
||||
|
||||
# Create fake X11
|
||||
create_fake_x ${VDISPLAY}
|
||||
create_fake_x "${VDISPLAY}"
|
||||
|
||||
# Load Xresources if specified.
|
||||
if [ -n "${XRDB_FILE}" ]
|
||||
then
|
||||
echo -e "${COLOR_YELLOW}Loading Xresources:${RESET} ${XRDB_FILE}"
|
||||
${XRDB} -retain -load ${XRDB_FILE}
|
||||
${XRDB} -retain -load "${XRDB_FILE}"
|
||||
fi
|
||||
|
||||
(generate | ${ROFI} -config "${XRDB_FILE}" -dmenu ${ROFI_OPTIONS} > /dev/null )&
|
||||
|
@@ -10,7 +10,7 @@
|
||||
# preferred terminal emulator. On Debian, there is the x-terminal-emulator
|
||||
# symlink for example.
|
||||
for terminal in $TERMINAL x-terminal-emulator urxvt rxvt st terminology qterminal Eterm aterm uxterm xterm roxterm xfce4-terminal.wrapper mate-terminal lxterminal konsole alacritty kitty; do
|
||||
if command -v $terminal > /dev/null 2>&1; then
|
||||
if command -v $terminal >/dev/null 2>&1; then
|
||||
exec $terminal "$@"
|
||||
fi
|
||||
done
|
||||
|
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
|
||||
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
|
||||
#
|
||||
|
||||
|
||||
ROFI=$(which rofi)
|
||||
SED=$(which sed)
|
||||
MKTEMP=$(which mktemp)
|
||||
@@ -37,7 +36,7 @@ declare -a theme_names
|
||||
# Function that tries to find all installed rofi themes.
|
||||
# This fills in #themes array and formats a displayable string #theme_names
|
||||
##
|
||||
function find_themes()
|
||||
find_themes()
|
||||
{
|
||||
DIRS=${XDG_DATA_DIRS}
|
||||
OLDIFS=${IFS}
|
||||
@@ -70,8 +69,8 @@ function find_themes()
|
||||
# Add user dir.
|
||||
DIRS+=":${XDG_DATA_HOME:-${HOME}/.local/share}"
|
||||
DIRS+=":${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
for p in ${DIRS}; do
|
||||
p=${p%/}
|
||||
for p in ${DIRS}; do
|
||||
p=${p%/}
|
||||
TD=${p}/rofi/themes
|
||||
if [ -n "${p}" ] && [ -d "${TD}" ]
|
||||
then
|
||||
@@ -80,10 +79,10 @@ function find_themes()
|
||||
do
|
||||
if [ -f "${file}" ]
|
||||
then
|
||||
themes+=(${file})
|
||||
FN=$(basename ${file})
|
||||
themes+=("${file}")
|
||||
FN=$(basename "${file}")
|
||||
NAME=${FN%.*}
|
||||
USER=$(${SED} -n 's/^.*User: \(.*\)/\1/p' ${file} | head -n 1 )
|
||||
USER=$(${SED} -n 's/^.*User: \(.*\)/\1/p' "${file}" | head -n 1 )
|
||||
if [ -z "${USER}" ]
|
||||
then
|
||||
theme_names+=(${NAME})
|
||||
@@ -95,29 +94,28 @@ function find_themes()
|
||||
fi
|
||||
done
|
||||
IFS=${OLDIFS}
|
||||
|
||||
}
|
||||
|
||||
##
|
||||
# Create a copy of rofi
|
||||
##
|
||||
function create_config_copy()
|
||||
create_config_copy()
|
||||
{
|
||||
${ROFI} -dump-config > ${TMP_CONFIG_FILE}
|
||||
${ROFI} -dump-config > "${TMP_CONFIG_FILE}"
|
||||
# remove theme entry.
|
||||
sed -i 's/^\s*theme:\s\+".*"\s*;//g' ${TMP_CONFIG_FILE}
|
||||
sed -i 's/^\s*theme:\s\+".*"\s*;//g' "${TMP_CONFIG_FILE}"
|
||||
}
|
||||
|
||||
###
|
||||
# Print the list out so it can be displayed by rofi.
|
||||
##
|
||||
function create_theme_list()
|
||||
create_theme_list()
|
||||
{
|
||||
OLDIFS=${IFS}
|
||||
IFS='|'
|
||||
for themen in ${theme_names[@]}
|
||||
for themen in ${theme_names[@]}
|
||||
do
|
||||
echo ${themen}
|
||||
echo "${themen}"
|
||||
done
|
||||
IFS=${OLDIFS}
|
||||
}
|
||||
@@ -127,9 +125,9 @@ function create_theme_list()
|
||||
##
|
||||
declare -i SELECTED
|
||||
|
||||
function select_theme ()
|
||||
select_theme()
|
||||
{
|
||||
local MORE_FLAGS=(-dmenu -format i -no-custom -p "Theme" -markup -config ${TMP_CONFIG_FILE} -i)
|
||||
local MORE_FLAGS=(-dmenu -format i -no-custom -p "Theme" -markup -config "${TMP_CONFIG_FILE}" -i)
|
||||
MORE_FLAGS+=(-kb-custom-1 "Alt-a")
|
||||
MORE_FLAGS+=(-u 2,3 -a 4,5 )
|
||||
local CUR="default"
|
||||
@@ -143,23 +141,23 @@ function select_theme ()
|
||||
Current theme: <b>${CUR}</b>"""
|
||||
THEME_FLAG=
|
||||
if [ -n "${SELECTED}" ]
|
||||
then
|
||||
THEME_FLAG="-theme ${themes[${SELECTED}]}"
|
||||
then
|
||||
THEME_FLAG="-theme ${themes[${SELECTED}]}"
|
||||
fi
|
||||
RES=$( create_theme_list | ${ROFI} ${THEME_FLAG} ${MORE_FLAGS[@]} -cycle -selected-row "${SELECTED}" -mesg "${MESG}")
|
||||
RES=$( create_theme_list | ${ROFI} ${THEME_FLAG} ${MORE_FLAGS[@]} -cycle -selected-row "${SELECTED}" -mesg "${MESG}")
|
||||
RTR=$?
|
||||
if [ ${RTR} = 10 ]
|
||||
if [ "${RTR}" = 10 ]
|
||||
then
|
||||
return 0;
|
||||
elif [ ${RTR} = 1 ]
|
||||
elif [ "${RTR}" = 1 ]
|
||||
then
|
||||
return 1;
|
||||
elif [ ${RTR} = 65 ]
|
||||
elif [ "${RTR}" = 65 ]
|
||||
then
|
||||
return 1;
|
||||
fi
|
||||
CUR=${theme_names[${RES}]}
|
||||
SELECTED=${RES}
|
||||
SELECTED=${RES}
|
||||
done
|
||||
}
|
||||
|
||||
@@ -167,12 +165,12 @@ Current theme: <b>${CUR}</b>"""
|
||||
# Create if not exists, then removes #include of .theme file (if present) and add the selected theme to the end.
|
||||
# Repeated calls should leave the config clean-ish
|
||||
###
|
||||
function set_theme()
|
||||
set_theme()
|
||||
{
|
||||
CDIR="${XDG_CONFIG_HOME:-${HOME}/.config}/rofi"
|
||||
if [ ! -d "${CDIR}" ]
|
||||
then
|
||||
mkdir -p ${CDIR}
|
||||
mkdir -p "${CDIR}"
|
||||
fi
|
||||
get_link=$(readlink -f "${CDIR}/config.rasi")
|
||||
${SED} -i "/@import.*/d" "${get_link}"
|
||||
@@ -213,4 +211,4 @@ fi
|
||||
##
|
||||
# Remove temp. config.
|
||||
##
|
||||
rm ${TMP_CONFIG_FILE}
|
||||
rm -- "${TMP_CONFIG_FILE}"
|
||||
|
Reference in New Issue
Block a user