 
 (defun aim/on-frame-open (frame)
   (interactive)
-  ;;(message "before FRAME %s" (frame-parameters frame))
+  (message "before FRAME %s" (frame-parameters frame))
+  (message "before FRAME background-mode %s" (frame-parameter frame 'background-mode))
+  (message "before FRAME foreground-mode %s" (frame-parameter frame 'foreground-mode))
   (if (not (display-graphic-p frame))
       (progn
-	(if (and (equal (frame-parameter frame 'background-mode) 'dark)
+	(if (and (equal (frame-parameter frame 'background-mode) 'light)
 		 (aim/frame-colours-unspecified frame))
 	    (progn
 	      (set-frame-parameter frame 'background-color "#000000")
-	      (set-frame-parameter frame 'foreground-color "#FFFFFF")
-	(if (and (equal (frame-parameter frame 'background-mode) 'light)
-		 (aim/frame-colours-unspecified frame))
-	    (progn
-	      (set-frame-parameter frame 'background-color "#FFFFFF")
-	      (set-frame-parameter frame 'foreground-color "#000000")
-	;; (if (equal (frame-parameter frame 'background-color) "white")
-	;;     (set-frame-parameter frame 'background-color "brightwhite"))
-	      (message "after FRAME %s" (frame-parameters frame)))))))))
+	      (set-frame-parameter frame 'foreground-color "#FFFFFF"))
+	  (if (and (equal (frame-parameter frame 'background-mode) 'dark)
+		   (aim/frame-colours-unspecified frame))
+	      (progn
+		(set-frame-parameter frame 'background-color "#FFFFFF")
+		(set-frame-parameter frame 'foreground-color "#000000"))))))
+  (message "after FRAME %s" (frame-parameters frame)))
 
 ;; (aim/on-frame-open (selected-frame))
 ;; (add-hook 'after-make-frame-functions 'aim/on-frame-open 'append)

 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ag-arguments (quote ("--smart-case" "--stats" "--follow")))
 '(c-default-style
   (quote
    ((c-mode . "linux")

(defun browse-url-chromote (url &rest ignore)
  "Browse URL using browse-url-chromote."
  (interactive "sURL: ")
  (shell-command (concat "/home/aim/bin/browse-url-chromote " url)))

;;(setq browse-url-browser-function 'browse-url-chromote)

(aim/set-global-keybindings)

(defun endless/visit-notifications ()
  (interactive)
  (endless/count-for-mode-line nil)
  (browse-url "https://github.com/notifications"))

(defvar endless/gh-mode-line nil)

(defun endless/count-for-mode-line (data)
  (setq endless/gh-mode-line
	(when data
	  (format " GH-%s" (length data))))
  (force-mode-line-update))

(add-to-list 'global-mode-string
	     '(endless/gh-mode-line
	       (:propertize endless/gh-mode-line
			    local-map (keymap (mode-line keymap (mouse-1 . endless/visit-notifications)))
			    mouse-face mode-line-highlight)))

;; If already installed, this does nothing.

(package-install 'paradox)
(autoload 'paradox--github-action "paradox-github")
(defun endless/check-gh-notifications ()
  (interactive)
  "Check for github notifications and update the mode-line."
  (paradox--github-action "notifications"
    :reader (lambda ()
              (let ((json-false nil)
                    (json-array-type 'list))
                (json-read)))
    :callback #'endless/count-for-mode-line))

(defvar endless/gh-timer
  (when (bound-and-true-p paradox-github-token)
    (run-with-idle-timer 30 'repeat
                         #'endless/check-gh-notifications)))

(use-package github-notifier
  :ensure t)
