Here is what I have now: press f12 to switch from a pre-configured full screen emacs window and the current window. I can run terminal commands, open frequently used files, take notes and do mathematical calculation (maxima) in emacs. Press f12 again brings me back to the previous application I was using.
The idea is as follows:
(1) Use emacsclient to build up the above window. I didn't find an intuitive way. Thus I use commands like
emacsclient -e '(split-window-horizontally)'to modify the emacsclient window frame.
(2) Use wmctrl, a command-line tool to get window information as well as change window size and focus, to bring emacs to front or to send it back.
(3) Finally, bind the script to a hotkey f12 using system settings.
The scripts are attached
(a) the script to toggle emacs state (get focus or not), should assign a hotkey
#!/bin/bash
TMPFN=/tmp/toggle_emacsorg_state
LOGFN=/tmp/toggle_emacsorg_log
CUR_WIN=$(wmctrl -v -r :ACTIVE: -e dummy 2>/dev/stdout|grep Using|sed 's/Using window: //')
if [ "$(wmctrl -l | grep $CUR_WIN | grep work_in_emacs)" == "" ]; then
echo "not in work_in_emacs frame, goto work_in_emacs" >> $LOGFN
# save current frame number to $TMPFN
echo $CUR_WIN > $TMPFN
# start work_in_emacs, and / or switch to that
if [ "$(wmctrl -l|grep work_in_emacs)" == "" ]; then
echo "start emacsorg.sh"
/home/wangyi/Dropbox/local/bin/emacsorg.sh;
else
echo "switch to emacsorg.sh" >> $LOGFN
wmctrl -a 'work_in_emacs'; # or using -R to bring to current desktop
fi
else
echo "in work_in_emacs frame, goto the previous frame $TMPFN" >> $LOGFN
if [ -a $TMPFN ]; then
wmctrl -i -a $(cat $TMPFN)
fi
fi
(b) the script to create emacs frame
#!/bin/bash
PRFX=~/Dropbox/elite/links
# emacs
if [ "$(ps aux |grep 'emacs --daemon'|grep -v grep)" == "" ]; then
LC_CTYPE=zh_CN.utf8 emacs --daemon;
fi
# window 1
emacsclient -c -n $PRFX/unclassified_notes.org
emacsclient -e '(set-frame-name "work_in_emacs")'
# window 2
emacsclient -e '(split-window-horizontally)'
#emacsclient -e '(shell)'
emacsclient -e '(term "/bin/bash")'
# window 3
emacsclient -e '(split-window-vertically)'
emacsclient -n $PRFX/favorates.org
# window 4
emacsclient -e '(split-window-horizontally)'
emacsclient -n $PRFX/todo.org
# emacsclient -e '(org-agenda-file-to-front)'
# window 5
emacsclient -e '(other-window 3)'
emacsclient -e '(split-window-vertically)'
emacsclient -n $PRFX/work.org
# window 6
emacsclient -e '(other-window 1)'
emacsclient -e '(split-window-vertically)'
emacsclient -e '(other-window 1)'
emacsclient -e '(maxima)'
# switch to terminal
emacsclient -e '(other-window 3)'
# maximize window
wmctrl -b add,maximized_vert,maximized_horz -r "work_in_emacs"
# wmctrl -b add,fullscreen -r "work_in_emacs"
No comments:
Post a Comment