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' # # dmenu_drun - dmenu script that simulates 'rofi -show drun' #
# # # #
# Author: q3aql <q3aql@duck.com> # # 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="/usr/share/applications"
desktop_files_home="${HOME}/.local/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 if [ -d "${desktop_files}" ] ; then
ls -1 "${desktop_files}/" | grep ".desktop" ls -1 "${desktop_files}/" | grep ".desktop"
fi fi
@ -19,7 +39,7 @@ list_desktop_files() {
fi fi
} }
list_desktop_icons() { function list_desktop_icons() {
list_desktop_files | while read current_desktop ; do list_desktop_files | while read current_desktop ; do
echo " ${current_desktop}" echo " ${current_desktop}"
done done
@ -30,7 +50,7 @@ rundesk () {
echo "No file entry" echo "No file entry"
else else
if [ -f "${1}" ] ; then if [ -f "${1}" ] ; then
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1")" eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1" | head -1)"
else else
echo "File does not exist" echo "File does not exist"
fi fi
@ -43,7 +63,8 @@ else
runDesktop="rundesk" runDesktop="rundesk"
fi 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) run_output=$(echo ${list_output} | cut -c 4-999)
system_file=$(echo -n ${desktop_files}/ ; echo ${run_output}) system_file=$(echo -n ${desktop_files}/ ; echo ${run_output})
home_file=$(echo -n ${desktop_files_home}/ ; 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' # # dmenu_fbrun - dmenu script that simulates 'rofi -show filebrowser' #
# # # #
# Author: q3aql <q3aql@duck.com> # # 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 ls -1 | while read current ; do
if [ -f "${current}" ] ; then if [ -f "${current}" ] ; then
echo " ${current}" echo " ${current}"
@ -19,7 +40,7 @@ show_icon_tree() {
done done
} }
remove_icon() { function remove_icon() {
entry="${@}" entry="${@}"
remove_icon_space=0 remove_icon_space=0
read_entry=$(echo "${entry}" | grep " ") read_entry=$(echo "${entry}" | grep " ")
@ -42,9 +63,10 @@ remove_icon() {
fi fi
} }
load_theme
file=1 file=1
while [ "${file}" ]; do 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}") file=$(remove_icon "${file_icon}")
echo "# ${file} #" echo "# ${file} #"
if [ -e "${file}" ]; then if [ -e "${file}" ]; then

View File

@ -4,10 +4,31 @@
# dmenu_run - dmenu script that simulates 'rofi -show run' # # dmenu_run - dmenu script that simulates 'rofi -show run' #
# # # #
# Author: q3aql <q3aql@duck.com> # # 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 binaries=0
path_binaries=${PATH} path_binaries=${PATH}
count_path=1 count_path=1
@ -17,24 +38,24 @@ list_binaries() {
binaries=1 binaries=1
else else
# Extra code / When /bin is the same that /usr/bin/ # Extra code / When /bin is the same that /usr/bin/
#if [ "${current_path}" == "/bin" ] ; then bin_same=$(ls -la ${current_path} | grep "> usr/bin")
# count_path=$(expr ${count_path} + 1) if [ -z "${bin_same}" ] ; then
#else ls -1 ${current_path}/
# ls -1 ${current_path}/ count_path=$(expr ${count_path} + 1)
# count_path=$(expr ${count_path} + 1) else
#fi count_path=$(expr ${count_path} + 1)
ls -1 ${current_path}/ fi
count_path=$(expr ${count_path} + 1)
fi fi
done done
} }
list_binaries_icons() { function list_binaries_icons() {
list_binaries | while read current_binary ; do list_binaries | while read current_binary ; do
echo " ${current_binary}" echo " ${current_binary}"
done 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=$(echo "${list_output}" | cut -c4-999)
${run_output} ${run_output}

View File

@ -4,22 +4,172 @@
# dmenu_themes - dmenu script that simulates 'rofi-theme-selector' # # dmenu_themes - dmenu script that simulates 'rofi-theme-selector' #
# # # #
# Author: q3aql <q3aql@duck.com> # # Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 # # Last update: 10-07-2022 #
#################################################################### ####################################################################
main_folder="/opt/dmenu-scripts/" # Configuration variables
folder_themes="/opt/dmenu-scripts/themes" 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 function load_theme() {
termrun="kitty --title dmenu_themes -c=/opt/dmenu-scripts/scripts/kitty.conf -e" if [ -f "${load_theme_file}" ] ; then
else source "${load_theme_file}"
xrdb -load /opt/dmenu-scripts/scripts/Xresources else
termrun="xterm -T dmenu_themes -e" mkdir -p "${load_theme_path}"
fi 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() { function load_themes_files() {
ls -1 ${folder_themes} | while read current ; do count_themes=$(ls -1 "${load_themes}/" | wc -l)
if [ -f "${folder_themes}/${current}" ] ; then 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}" echo " ${current}"
else else
echo " ${current}" echo " ${current}"
@ -27,7 +177,7 @@ show_icon_tree() {
done done
} }
remove_icon() { function remove_icon() {
entry="${@}" entry="${@}"
remove_icon_space=0 remove_icon_space=0
read_entry=$(echo "${entry}" | grep " ") read_entry=$(echo "${entry}" | grep " ")
@ -42,21 +192,20 @@ remove_icon() {
fi fi
} }
function load_theme() { function load_theme_selector() {
file_icon=$(show_icon_tree | dmenu -p " Theme:") file_icon=$(show_icon_tree | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " Theme:")
file=$(remove_icon "${file_icon}") file=$(remove_icon "${file_icon}")
if [ -z "${file}" ] ; then if [ -z "${file}" ] ; then
echo "# Theme selector canceled" echo "# Theme selector canceled"
else else
if [ -f /usr/bin/sudo ] ; then cp -rf ${load_themes}/${file} ${load_theme_file}
${termrun} sudo ${main_folder}/scripts/build-theme.sh "${file}" load_theme
load_theme load_theme_selector
else
${termrun} su -c ${main_folder}/scripts/build-theme.sh "${file}"
fi
fi fi
} }
# Run main function for load theme # Run main function for load theme
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' # # dmenu_wrun - dmenu script that simulates 'rofi -show window' #
# # # #
# Author: q3aql <q3aql@duck.com> # # 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') list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g')
for process in ${list_raw}; do for process in ${list_raw}; do
echo "${process}" echo "${process}"
done done
} }
list_applications_icons() { function list_applications_icons() {
list_applications | while read current_app ; do list_applications | while read current_app ; do
echo " ${current_app}" echo " ${current_app}"
done 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) run_output=$(echo ${list_output} | cut -c 4-999)
if [ "${run_output}" == "gimp" ] ; then if [ "${run_output}" == "gimp" ] ; then
xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null