+;;;; Fix environment if called as GUI app
+;; =============================================================================
+(defun md/get-dotfiles-path ()
+  (or
+    (getenv "DOTFILES")
+    (concat (expand-file-name "~") "/dotfiles")))
+
 ;;;; Reload
+;; =============================================================================
 (defun md/dotfiles-reload ()
     (interactive)
-    (load-file (concat (getenv "DOTFILES") "/emacs.d.symlink/init.el")))
+    (load-file (concat (md/get-dotfiles-path) "/emacs.d.symlink/init.el")))
 
 ;;;; Download and install packages
 ;; =============================================================================

;;;; Custom
;; =============================================================================

(setq custom-file (concat (getenv "DOTFILES") "/emacs.d.symlink/custom.el"))
(load custom-file 'noerror)

(savehist-mode 1)

;;;; Load external files
;; =============================================================================

(load-file (concat (md/get-dotfiles-path) "/splitscreen/splitscreen.el"))

;;;; Backups
;; =============================================================================

;; Backup everything to the same directory, rather than dropping
;; files all over the place
(setq backup-directory-alist
      `(("." . ,(concat (md/get-dotfiles-path) "/emacs.d.symlink/.backups"))))

;;;; General
(setq confirm-kill-emacs 'yes-or-no-p)
