From dad226f547ea70fbd22c2061e39216f475905b6d Mon Sep 17 00:00:00 2001 From: Abhay Rana Date: Mon, 8 Aug 2016 12:30:49 +0530 Subject: [PATCH] [display] Adds toggle option to my display script --- files/bash/.bashrc | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/files/bash/.bashrc b/files/bash/.bashrc index e5b4f5d..6fc69a1 100644 --- a/files/bash/.bashrc +++ b/files/bash/.bashrc @@ -363,13 +363,31 @@ xset -b # Overrides the display provided by imagemagick function display() { - `cd ~/.screenlayout && sh $1.sh` - # Write the current layout - echo $1 > ~/.screenlayout/current - if [[ -e "~/Pictures/$1.jpg" ]]; then - (cd ~/Pictures && cp "$1.jpg" "./xin_1.jpg") + layout="$1" + if [[ "$1" == "toggle" ]]; then + # exchange it + CURRENT=$(cat ~/.screenlayout/current) + echo "current=$CURRENT" + case "$CURRENT" in + "office") + layout="single" + ;; + "single") + layout="office" + ;; + esac + fi + echo "layout=$layout" + if [[ -a ~/.screenlayout/$layout.sh ]]; then + `cd ~/.screenlayout && sh $layout.sh` + # Write the current layout + echo $layout > ~/.screenlayout/current + if [[ -e "~/Pictures/$layout.jpg" ]]; then + (cd ~/Pictures && cp "$layout.jpg" "./xin_1.jpg") + fi + nitrogen --restore >/dev/null 2>&1 + i3-msg reload fi - nitrogen --restore } #SCM Breeze