Reload herbstluftwm configuration only if running
This commit is contained in:
parent
4b51ddb627
commit
37629b6e70
56
ecran
56
ecran
|
@ -4,9 +4,6 @@
|
||||||
# And reload wm configuration
|
# And reload wm configuration
|
||||||
|
|
||||||
# Vars {{{
|
# Vars {{{
|
||||||
## First and main screen (laptop screen,…)
|
|
||||||
readonly MAIN_OUTPUT_NAME="LVDS-1"
|
|
||||||
|
|
||||||
[ -z "${DEBUG}" ] && readonly DEBUG=0
|
[ -z "${DEBUG}" ] && readonly DEBUG=0
|
||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
|
@ -14,6 +11,10 @@ readonly PURPLE='\033[1;35m'
|
||||||
readonly RED='\033[0;31m'
|
readonly RED='\033[0;31m'
|
||||||
readonly RESET='\033[0m'
|
readonly RESET='\033[0m'
|
||||||
readonly COLOR_DEBUG="${PURPLE}"
|
readonly COLOR_DEBUG="${PURPLE}"
|
||||||
|
|
||||||
|
## First and main screen (laptop screen,…)
|
||||||
|
readonly MAIN_OUTPUT_NAME="LVDS-1"
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
debug_message() { # {{{
|
debug_message() { # {{{
|
||||||
|
@ -38,15 +39,40 @@ The second connected output is: ${SECOND_OUTPUT_NAME}."
|
||||||
return "${return_second_output_name}"
|
return "${return_second_output_name}"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
main() { # {{{
|
is_proc_running() { # {{{
|
||||||
|
|
||||||
## Define all vars
|
local_proc_pattern="${1}"
|
||||||
define_vars
|
|
||||||
|
local_count_proc_pattern="$(pgrep -f -- "${local_proc_pattern}" | wc -l)"
|
||||||
|
|
||||||
|
case "${local_count_proc_pattern}" in
|
||||||
|
0 ) ## No procs related to this pattern are running
|
||||||
|
return_proc_running="1"
|
||||||
|
;;
|
||||||
|
* ) ## At least one proc seems running
|
||||||
|
return_proc_running="0"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
## Simple debug message to valid current variables
|
||||||
|
debug_message "is_proc_running − \
|
||||||
|
procs running (with the pattern: ${RED}${local_proc_pattern}${COLOR_DEBUG}) on the current host: ${RED}${local_count_proc_pattern}${COLOR_DEBUG}."
|
||||||
|
|
||||||
|
return "${return_proc_running}"
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
main() { # {{{
|
||||||
|
|
||||||
main
|
## Update herbstluftwm Window Manager configuration if it's running
|
||||||
|
is_proc_running "herbstluftwm" \
|
||||||
|
&& herbstclient detect_monitors \
|
||||||
|
&& herbstclient reload
|
||||||
|
}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
## Define all vars
|
||||||
|
define_vars
|
||||||
|
|
||||||
# Manage arguments # {{{
|
# Manage arguments # {{{
|
||||||
# This code can't be in a function due to arguments
|
# This code can't be in a function due to arguments
|
||||||
|
@ -55,20 +81,20 @@ case "${1}" in
|
||||||
## TODO : One command to enable main screen and a loop to disable all other connected output
|
## TODO : One command to enable main screen and a loop to disable all other connected output
|
||||||
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off --output VGA-1 --off --output HDMI-3 --off --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off
|
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off --output VGA-1 --off --output HDMI-3 --off --output "${SECOND_OUTPUT_NAME:=/dev/null}" --off
|
||||||
xrandr --output VGA --off
|
xrandr --output VGA --off
|
||||||
printf 'Desactivate all video output'
|
printf "%b\n" 'Desactivate all video output'
|
||||||
;;
|
;;
|
||||||
leftof | left-of | ds | dockstation | work )
|
leftof | left-of | ds | dockstation | work )
|
||||||
#xrandr --output VGA-1 --mode 1024x768 --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --mode 1366x768
|
#xrandr --output VGA-1 --mode 1024x768 --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --mode 1366x768
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --left-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
printf 'Xrandr for second output left-of main screen'
|
printf "%b\n" 'Xrandr for second output left-of main screen'
|
||||||
;;
|
;;
|
||||||
rightof | right-of | home )
|
rightof | right-of | home )
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --right-of "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
printf 'Xrandr for second output left-of main screen'
|
printf "%b\n" 'Xrandr for second output left-of main screen'
|
||||||
;;
|
;;
|
||||||
above )
|
above )
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --above "${MAIN_OUTPUT_NAME:=/dev/null}" --output "${MAIN_OUTPUT_NAME:=/dev/null}" --auto
|
||||||
printf 'Xrandr for dual screen with DisplayPort'
|
printf "%b\n" 'Xrandr for dual screen with DisplayPort'
|
||||||
;;
|
;;
|
||||||
out | game )
|
out | game )
|
||||||
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
xrandr --output "${SECOND_OUTPUT_NAME:=/dev/null}" --auto --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
||||||
|
@ -77,15 +103,13 @@ case "${1}" in
|
||||||
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
xrandr --output "${MAIN_OUTPUT_NAME:=/dev/null}" --off
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
printf 'Bad argument, please use [vga|hdmi|ds|work|off]'
|
printf "%b\n" 'Bad argument, please use [vga|hdmi|ds|work|off]'
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Update herbstluftWM configuration
|
|
||||||
herbstclient detect_monitors
|
|
||||||
herbstclient reload
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue