Better support for themes

This commit is contained in:
q3aql 2022-07-10 16:21:44 +02:00
parent bd3efe0f12
commit 17be0486d0
5 changed files with 281 additions and 46 deletions

View File

@ -4,13 +4,33 @@
# dmenu_drun - dmenu script that simulates 'rofi -show drun' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
# Last update: 10-07-2022 #
##############################################################
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
desktop_files="/usr/share/applications"
desktop_files_home="${HOME}/.local/share/applications"
list_desktop_files() {
function load_theme() {
if [ -f "${load_theme_file}" ] ; then
source "${load_theme_file}"
else
mkdir -p "${load_theme_path}"
mkdir -p "${load_themes}"
echo "#!/bin/bash" > ${load_theme_file}
echo "" >> ${load_theme_file}
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
source "${load_theme_file}"
fi
}
function list_desktop_files() {
if [ -d "${desktop_files}" ] ; then
ls -1 "${desktop_files}/" | grep ".desktop"
fi
@ -19,7 +39,7 @@ list_desktop_files() {
fi
}
list_desktop_icons() {
function list_desktop_icons() {
list_desktop_files | while read current_desktop ; do
echo " ${current_desktop}"
done
@ -30,7 +50,7 @@ rundesk () {
echo "No file entry"
else
if [ -f "${1}" ] ; then
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1")"
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1" | head -1)"
else
echo "File does not exist"
fi
@ -43,7 +63,8 @@ else
runDesktop="rundesk"
fi
list_output=$(list_desktop_icons | dmenu "$@" -p " drun:")
load_theme
list_output=$(list_desktop_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " drun:")
run_output=$(echo ${list_output} | cut -c 4-999)
system_file=$(echo -n ${desktop_files}/ ; echo ${run_output})
home_file=$(echo -n ${desktop_files_home}/ ; echo ${run_output})

View File

@ -4,10 +4,31 @@
# dmenu_fbrun - dmenu script that simulates 'rofi -show filebrowser' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
# Last update: 10-07-2022 #
######################################################################
show_icon_tree() {
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
function load_theme() {
if [ -f "${load_theme_file}" ] ; then
source "${load_theme_file}"
else
mkdir -p "${load_theme_path}"
mkdir -p "${load_themes}"
echo "#!/bin/bash" > ${load_theme_file}
echo "" >> ${load_theme_file}
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
source "${load_theme_file}"
fi
}
function show_icon_tree() {
ls -1 | while read current ; do
if [ -f "${current}" ] ; then
echo " ${current}"
@ -19,7 +40,7 @@ show_icon_tree() {
done
}
remove_icon() {
function remove_icon() {
entry="${@}"
remove_icon_space=0
read_entry=$(echo "${entry}" | grep " ")
@ -42,9 +63,10 @@ remove_icon() {
fi
}
load_theme
file=1
while [ "${file}" ]; do
file_icon=$(show_icon_tree | dmenu -p " filebrowser: $(basename $(pwd))")
file_icon=$(show_icon_tree | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " filebrowser: $(basename $(pwd))")
file=$(remove_icon "${file_icon}")
echo "# ${file} #"
if [ -e "${file}" ]; then

View File

@ -4,10 +4,31 @@
# dmenu_run - dmenu script that simulates 'rofi -show run' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
# Last update: 10-07-2022 #
############################################################
list_binaries() {
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
function load_theme() {
if [ -f "${load_theme_file}" ] ; then
source "${load_theme_file}"
else
mkdir -p "${load_theme_path}"
mkdir -p "${load_themes}"
echo "#!/bin/bash" > ${load_theme_file}
echo "" >> ${load_theme_file}
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
source "${load_theme_file}"
fi
}
function list_binaries() {
binaries=0
path_binaries=${PATH}
count_path=1
@ -17,24 +38,24 @@ list_binaries() {
binaries=1
else
# Extra code / When /bin is the same that /usr/bin/
#if [ "${current_path}" == "/bin" ] ; then
# count_path=$(expr ${count_path} + 1)
#else
# ls -1 ${current_path}/
# count_path=$(expr ${count_path} + 1)
#fi
ls -1 ${current_path}/
count_path=$(expr ${count_path} + 1)
bin_same=$(ls -la ${current_path} | grep "> usr/bin")
if [ -z "${bin_same}" ] ; then
ls -1 ${current_path}/
count_path=$(expr ${count_path} + 1)
else
count_path=$(expr ${count_path} + 1)
fi
fi
done
}
list_binaries_icons() {
function list_binaries_icons() {
list_binaries | while read current_binary ; do
echo " ${current_binary}"
done
}
list_output=$(list_binaries_icons | dmenu "$@" -p " run:")
load_theme
list_output=$(list_binaries_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " run:")
run_output=$(echo "${list_output}" | cut -c4-999)
${run_output}

View File

@ -4,22 +4,172 @@
# dmenu_themes - dmenu script that simulates 'rofi-theme-selector' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
# Last update: 10-07-2022 #
####################################################################
main_folder="/opt/dmenu-scripts/"
folder_themes="/opt/dmenu-scripts/themes"
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
if [ -f /usr/bin/kitty ] ; then
termrun="kitty --title dmenu_themes -c=/opt/dmenu-scripts/scripts/kitty.conf -e"
else
xrdb -load /opt/dmenu-scripts/scripts/Xresources
termrun="xterm -T dmenu_themes -e"
fi
function load_theme() {
if [ -f "${load_theme_file}" ] ; then
source "${load_theme_file}"
else
mkdir -p "${load_theme_path}"
mkdir -p "${load_themes}"
echo "#!/bin/bash" > ${load_theme_file}
echo "" >> ${load_theme_file}
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
source "${load_theme_file}"
fi
}
show_icon_tree() {
ls -1 ${folder_themes} | while read current ; do
if [ -f "${folder_themes}/${current}" ] ; then
function load_themes_files() {
count_themes=$(ls -1 "${load_themes}/" | wc -l)
if [ ${count_themes} -lt 18 ] ; then
# Default Purple
echo "#!/bin/bash" > ${load_themes}/default-purple
echo "" >> ${load_themes}/default-purple
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/default-purple
echo "NBCOLOR=\"#1f1f35\"" >> ${load_themes}/default-purple
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/default-purple
echo "SBCOLOR=\"#664477\"" >> ${load_themes}/default-purple
# Cool Green
echo "#!/bin/bash" > ${load_themes}/cool-green
echo "" >> ${load_themes}/cool-green
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/cool-green
echo "NBCOLOR=\"#253829\"" >> ${load_themes}/cool-green
echo "SFCOLOR=\"#202118\"" >> ${load_themes}/cool-green
echo "SBCOLOR=\"#98c379\"" >> ${load_themes}/cool-green
# Dark Grey
echo "#!/bin/bash" > ${load_themes}/dark-grey
echo "" >> ${load_themes}/dark-grey
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/dark-grey
echo "NBCOLOR=\"#0f101a\"" >> ${load_themes}/dark-grey
echo "SFCOLOR=\"#0f101a\"" >> ${load_themes}/dark-grey
echo "SBCOLOR=\"#f1ffff\"" >> ${load_themes}/dark-grey
# Dracula
echo "#!/bin/bash" > ${load_themes}/dracula
echo "" >> ${load_themes}/dracula
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/dracula
echo "NBCOLOR=\"#292d3e\"" >> ${load_themes}/dracula
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/dracula
echo "SBCOLOR=\"#a77ac4\"" >> ${load_themes}/dracula
# Material Darker
echo "#!/bin/bash" > ${load_themes}/material-darker
echo "" >> ${load_themes}/material-darker
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/material-darker
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/material-darker
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/material-darker
echo "SBCOLOR=\"#a151d3\"" >> ${load_themes}/material-darker
# Material Darker
echo "#!/bin/bash" > ${load_themes}/material-darker
echo "" >> ${load_themes}/material-darker
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/material-darker
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/material-darker
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/material-darker
echo "SBCOLOR=\"#a151d3\"" >> ${load_themes}/material-darker
# Monokai
echo "#!/bin/bash" > ${load_themes}/monokai
echo "" >> ${load_themes}/monokai
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/monokai
echo "NBCOLOR=\"#1e1e2e\"" >> ${load_themes}/monokai
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/monokai
echo "SBCOLOR=\"#a32852\"" >> ${load_themes}/monokai
# Monokai Pro
echo "#!/bin/bash" > ${load_themes}/monokai-pro
echo "" >> ${load_themes}/monokai-pro
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/monokai-pro
echo "NBCOLOR=\"#2d2a2e\"" >> ${load_themes}/monokai-pro
echo "SFCOLOR=\"#2d2a2e\"" >> ${load_themes}/monokai-pro
echo "SBCOLOR=\"#a9dc76\"" >> ${load_themes}/monokai-pro
# Nice Blue
echo "#!/bin/bash" > ${load_themes}/nice-blue
echo "" >> ${load_themes}/nice-blue
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nice-blue
echo "NBCOLOR=\"#1b214a\"" >> ${load_themes}/nice-blue
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/nice-blue
echo "SBCOLOR=\"#3e4474\"" >> ${load_themes}/nice-blue
# Nord
echo "#!/bin/bash" > ${load_themes}/nord
echo "" >> ${load_themes}/nord
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nord
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/nord
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/nord
echo "SBCOLOR=\"#81a1c1\"" >> ${load_themes}/nord
# Nord Wave
echo "#!/bin/bash" > ${load_themes}/nord-wave
echo "" >> ${load_themes}/nord-wave
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nord-wave
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/nord-wave
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/nord-wave
echo "SBCOLOR=\"#ebcb8b\"" >> ${load_themes}/nord-wave
# Onedark
echo "#!/bin/bash" > ${load_themes}/onedark
echo "" >> ${load_themes}/onedark
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/onedark
echo "NBCOLOR=\"#1e2127\"" >> ${load_themes}/onedark
echo "SFCOLOR=\"#202118\"" >> ${load_themes}/onedark
echo "SBCOLOR=\"#98c379\"" >> ${load_themes}/onedark
# Orange
echo "#!/bin/bash" > ${load_themes}/orange
echo "" >> ${load_themes}/orange
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/orange
echo "NBCOLOR=\"#22222c\"" >> ${load_themes}/orange
echo "SFCOLOR=\"#22222c\"" >> ${load_themes}/orange
echo "SBCOLOR=\"#d05a1f\"" >> ${load_themes}/orange
# Psychedelic
echo "#!/bin/bash" > ${load_themes}/psychedelic
echo "" >> ${load_themes}/psychedelic
echo "NFCOLOR=\"#98c379\"" >> ${load_themes}/psychedelic
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/psychedelic
echo "SFCOLOR=\"#ef3a03\"" >> ${load_themes}/psychedelic
echo "SBCOLOR=\"#5457a9\"" >> ${load_themes}/psychedelic
# Red Sea
echo "#!/bin/bash" > ${load_themes}/red-sea
echo "" >> ${load_themes}/red-sea
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/red-sea
echo "NBCOLOR=\"#941835\"" >> ${load_themes}/red-sea
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/red-sea
echo "SBCOLOR=\"#c62570\"" >> ${load_themes}/red-sea
# Rosepine
echo "#!/bin/bash" > ${load_themes}/rosepine
echo "" >> ${load_themes}/rosepine
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/rosepine
echo "NBCOLOR=\"#1f1d29\"" >> ${load_themes}/rosepine
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/rosepine
echo "SBCOLOR=\"#eabbb9\"" >> ${load_themes}/rosepine
# Sunset
echo "#!/bin/bash" > ${load_themes}/sunset
echo "" >> ${load_themes}/sunset
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/sunset
echo "NBCOLOR=\"#9b3800\"" >> ${load_themes}/sunset
echo "SFCOLOR=\"#22222c\"" >> ${load_themes}/sunset
echo "SBCOLOR=\"#c59a4d\"" >> ${load_themes}/sunset
# White Heaven
echo "#!/bin/bash" > ${load_themes}/white-heaven
echo "" >> ${load_themes}/white-heaven
echo "NFCOLOR=\"#2d2d37\"" >> ${load_themes}/white-heaven
echo "NBCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-heaven
echo "SFCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-heaven
echo "SBCOLOR=\"#2d2d37\"" >> ${load_themes}/white-heaven
# White Wine
echo "#!/bin/bash" > ${load_themes}/white-wine
echo "" >> ${load_themes}/white-wine
echo "NFCOLOR=\"#861616\"" >> ${load_themes}/white-wine
echo "NBCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-wine
echo "SFCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-wine
echo "SBCOLOR=\"#861616\"" >> ${load_themes}/white-wine
fi
}
function show_icon_tree() {
ls -1 ${load_themes} | while read current ; do
if [ -f "${load_themes}/${current}" ] ; then
echo " ${current}"
else
echo " ${current}"
@ -27,7 +177,7 @@ show_icon_tree() {
done
}
remove_icon() {
function remove_icon() {
entry="${@}"
remove_icon_space=0
read_entry=$(echo "${entry}" | grep " ")
@ -42,21 +192,20 @@ remove_icon() {
fi
}
function load_theme() {
file_icon=$(show_icon_tree | dmenu -p " Theme:")
function load_theme_selector() {
file_icon=$(show_icon_tree | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " Theme:")
file=$(remove_icon "${file_icon}")
if [ -z "${file}" ] ; then
echo "# Theme selector canceled"
else
if [ -f /usr/bin/sudo ] ; then
${termrun} sudo ${main_folder}/scripts/build-theme.sh "${file}"
load_theme
else
${termrun} su -c ${main_folder}/scripts/build-theme.sh "${file}"
fi
cp -rf ${load_themes}/${file} ${load_theme_file}
load_theme
load_theme_selector
fi
}
# Run main function for load theme
load_theme
load_themes_files
load_theme_selector

View File

@ -4,23 +4,45 @@
# dmenu_wrun - dmenu script that simulates 'rofi -show window' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
# Last update: 10-07-2022 #
################################################################
list_applications() {
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
function load_theme() {
if [ -f "${load_theme_file}" ] ; then
source "${load_theme_file}"
else
mkdir -p "${load_theme_path}"
mkdir -p "${load_themes}"
echo "#!/bin/bash" > ${load_theme_file}
echo "" >> ${load_theme_file}
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
source "${load_theme_file}"
fi
}
function list_applications() {
list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g')
for process in ${list_raw}; do
echo "${process}"
done
}
list_applications_icons() {
function list_applications_icons() {
list_applications | while read current_app ; do
echo " ${current_app}"
done
}
list_output=$(list_applications_icons | dmenu "$@" -p " window:")
load_theme
list_output=$(list_applications_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " window:")
run_output=$(echo ${list_output} | cut -c 4-999)
if [ "${run_output}" == "gimp" ] ; then
xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null