From 035f0279468a5097cb81afcd2dc64cbff8847fd5 Mon Sep 17 00:00:00 2001 From: q3aql Date: Fri, 29 Jul 2022 18:36:18 +0200 Subject: [PATCH] Dotfiles config update (2022-07-29) --- .config/dmenu/Makefile | 6 ++- .config/dmenu/dmenu_close | 90 +++++++++++++++++++++++++++++++++++++++ .config/dmenu/dmenu_drun | 20 ++++++--- 3 files changed, 110 insertions(+), 6 deletions(-) create mode 100755 .config/dmenu/dmenu_close diff --git a/.config/dmenu/Makefile b/.config/dmenu/Makefile index f25d622..87cf61e 100644 --- a/.config/dmenu/Makefile +++ b/.config/dmenu/Makefile @@ -42,7 +42,9 @@ dist: clean install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dmenu dmenu_drun dmenu_run dmenu_wrun dmenu_fbrun dmenu_themes dmenu_cmd stest $(DESTDIR)$(PREFIX)/bin + mkdir -p /usr/share/fonts/truetype/ubuntumono/ + tar Jxvf fonts/ubuntumono-nerd-fonts.tar.xz -C /usr/share/fonts/truetype/ubuntumono/ + cp -f dmenu dmenu_drun dmenu_run dmenu_wrun dmenu_fbrun dmenu_themes dmenu_cmd dmenu_close stest $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_drun chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run @@ -50,6 +52,7 @@ install: all chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_fbrun chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_themes chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_cmd + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_close chmod 755 $(DESTDIR)$(PREFIX)/bin/stest mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 @@ -65,6 +68,7 @@ uninstall: $(DESTDIR)$(PREFIX)/bin/dmenu_fbrun\ $(DESTDIR)$(PREFIX)/bin/dmenu_themes\ $(DESTDIR)$(PREFIX)/bin/dmenu_cmd\ + $(DESTDIR)$(PREFIX)/bin/dmenu_close\ $(DESTDIR)$(PREFIX)/bin/stest\ $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\ $(DESTDIR)$(MANPREFIX)/man1/stest.1 diff --git a/.config/dmenu/dmenu_close b/.config/dmenu/dmenu_close new file mode 100755 index 0000000..baf1f06 --- /dev/null +++ b/.config/dmenu/dmenu_close @@ -0,0 +1,90 @@ +#!/bin/bash + +##################################################################### +# dmenu_close - dmenu script for poweroff/reboot/suspend and logout # +# # +# Author: q3aql # +# Last update: 29-07-2022 # +##################################################################### + +# 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 load_session_options() { + echo " Restart" + echo " Shutdown" + echo " Suspend" + dwm_session=$(ps -ef | grep " dwm" | grep -v "grep") + spectrwm_session=$(ps -ef | grep " spectrwm" | grep -v "grep") + qtile_session=$(ps -ef | grep " qtile" | grep -v "grep") + sway_session=$(ps -ef | grep " sway" | grep -v "grep") + i3_session=$(ps -ef | grep " i3" | grep -v "grep") + sessions_check="${dwm_session}${spectrwm_session}${qtile_session}${sway_session}${i3_session}" + if [ ! -z "${sessions_check}" ] ; then + echo " Logout" + fi +} + +function close_session() { + killall dwm + killall spectrwm + killall sway + killall i3 + qtile_pid=$(ps -ef | grep " qtile" | grep -v "grep" | tr -s " " | cut -d " " -f 2 | head -1) + if [ ! -z ${qtile_pid} ] ; then + kill ${qtile_pid} + fi +} + +function generate_spaces() { + num_spaces=${1} + count_spaces=1 + while [ ${count_spaces} -le ${num_spaces} ] ; do + echo -n " " + count_spaces=$(expr ${count_spaces} + 1) + done +} + +function run_action() { + load_theme + systemctl --version &> /dev/null + systemd_error=$? + if [ ${systemd_error} -eq 0 ] ; then + systemctl ${1} + else + echo > /dev/null | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " You need SystemD for ${1} $(generate_spaces 60)" + fi +} + +load_theme +list_output=$(load_session_options | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " Session:") +run_output=$(echo ${list_output} | cut -c 5-999) +if [ ! -z "${run_output}" ] ; then + if [ "${run_output}" == "Restart" ] ; then + run_action "reboot" + elif [ "${run_output}" == "Shutdown" ] ; then + run_action "poweroff" + elif [ "${run_output}" == "Suspend" ] ; then + run_action "suspend" + elif [ "${run_output}" == "Logout" ] ; then + close_session + fi +fi diff --git a/.config/dmenu/dmenu_drun b/.config/dmenu/dmenu_drun index 58738c4..e68f7e9 100755 --- a/.config/dmenu/dmenu_drun +++ b/.config/dmenu/dmenu_drun @@ -4,7 +4,7 @@ # dmenu_drun - dmenu script that simulates 'rofi -show drun' # # # # Author: q3aql # -# Last update: 20-07-2022 # +# Last update: 29-07-2022 # ############################################################## # Configuration variables @@ -16,6 +16,7 @@ desktop_files="/usr/share/applications" desktop_files_local="/usr/local/share/applications" desktop_files_home="${HOME}/.local/share/applications" desktop_files_flatpak="/var/lib/flatpak/exports/share/applications" +desktop_files_snap="/var/lib/snapd/desktop/applications" function load_theme() { if [ -f "${load_theme_file}" ] ; then @@ -46,12 +47,15 @@ function list_desktop_files() { if [ -d "${desktop_files_flatpak}" ] ; then ls -1 "${desktop_files_flatpak}/" | grep ".desktop" fi + if [ -d "${desktop_files_snap}" ] ; then + ls -1 "${desktop_files_snap}/" | grep ".desktop" + fi } function list_desktop_icons() { - echo " Scan New Desktop Files" + echo " Scan/Update Desktop Files" ls -1 "${load_desktop_files}/" | while read current_desktop ; do - echo " ${current_desktop}" + echo " ${current_desktop}" done } @@ -97,7 +101,13 @@ function create_list_files() { if [ -f "${desktop_files_flatpak}/${current_file}" ] ; then name_show=$(cat "${desktop_files_flatpak}/${current_file}" | grep "Name=" | head -1 | cut -d "=" -f 2 | sed 's/\//|/g') if [ ! -z "${name_show}" ] ; then - echo "${desktop_files_flatpak}/${current_file}" > "${load_desktop_files}/${name_show}" + echo "${desktop_files_flatpak}/${current_file}" > "${load_desktop_files}/${name_show} (Flatpak)" + fi + fi + if [ -f "${desktop_files_snap}/${current_file}" ] ; then + name_show=$(cat "${desktop_files_snap}/${current_file}" | grep "Name=" | head -1 | cut -d "=" -f 2 | sed 's/\//|/g') + if [ ! -z "${name_show}" ] ; then + echo "${desktop_files_snap}/${current_file}" > "${load_desktop_files}/${name_show} (Snap)" fi fi done @@ -116,7 +126,7 @@ create_list_files list_output=$(list_desktop_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " drun:") run_output=$(echo ${list_output} | cut -c 5-999) if [ ! -z "${run_output}" ] ; then - if [ "${run_output}" == "Scan New Desktop Files" ] ; then + if [ "${run_output}" == "Scan/Update Desktop Files" ] ; then echo "0" > ${HOME}/.dmenu/read_list create_list_files $0