Improved loading time of i3/.scripts/i3lock.py, by using scrot tweaked/cleanup emacs' config.org to enable literal programming
parent
9efe63cb57
commit
be5d797e9e
|
@ -2,9 +2,7 @@
|
||||||
\#*\#
|
\#*\#
|
||||||
*.log
|
*.log
|
||||||
.#*
|
.#*
|
||||||
emacs/.emacs.d/ac-comphist.dat
|
emacs/.emacs.d/*
|
||||||
emacs/.emacs.d/anaconda-mode/*
|
!emacs/.emacs.d/snippets*
|
||||||
emacs/.emacs.d/auto-save-list/*
|
!emacs/.emacs.d/config.org
|
||||||
emacs/.emacs.d/elpa/*
|
!emacs/.emacs.d/init.el
|
||||||
emacs/.emacs.d/recentf
|
|
||||||
emacs/.emacs.d/tramp
|
|
|
@ -1,164 +0,0 @@
|
||||||
|
|
||||||
(require 'package)
|
|
||||||
(add-to-list 'package-archives
|
|
||||||
'("melpa" . "http://melpa.org/packages/"))
|
|
||||||
(package-initialize)
|
|
||||||
|
|
||||||
(unless (package-installed-p 'use-package)
|
|
||||||
(package-refresh-contents)
|
|
||||||
(package-install 'use-package))
|
|
||||||
|
|
||||||
(require 'use-package)
|
|
||||||
(setq use-package-always-ensure t)
|
|
||||||
|
|
||||||
(use-package aggressive-indent)
|
|
||||||
(use-package anaconda-mode)
|
|
||||||
(use-package auto-complete)
|
|
||||||
(use-package auto-complete-auctex
|
|
||||||
:defer t
|
|
||||||
:ensure t)
|
|
||||||
(use-package auctex
|
|
||||||
:defer t
|
|
||||||
:ensure t)
|
|
||||||
(use-package counsel)
|
|
||||||
(use-package eclim)
|
|
||||||
(use-package flycheck)
|
|
||||||
(use-package google-this)
|
|
||||||
(use-package ivy)
|
|
||||||
(use-package material-theme)
|
|
||||||
(use-package ox-twbs)
|
|
||||||
(use-package rainbow-delimiters)
|
|
||||||
(use-package rainbow-mode)
|
|
||||||
(use-package smartparens)
|
|
||||||
(use-package swiper)
|
|
||||||
(use-package yasnippet)
|
|
||||||
|
|
||||||
(load-theme 'material t)
|
|
||||||
|
|
||||||
(add-hook 'window-setup-hook
|
|
||||||
'(lambda ()
|
|
||||||
(set-face-background 'default "unspecified-bg")))
|
|
||||||
|
|
||||||
(f-mkdir "~/.emacs-saves")
|
|
||||||
(setq auto-save-file-name-transforms
|
|
||||||
'((".*" "~/.emacs-saves/" t)))
|
|
||||||
|
|
||||||
(defun copy-to-xclipboard(arg)
|
|
||||||
(interactive "P")
|
|
||||||
(cond
|
|
||||||
((not (use-region-p))
|
|
||||||
(message "Nothing to yank to X-clipboard"))
|
|
||||||
((and (not (display-graphic-p))
|
|
||||||
(/= 0 (shell-command-on-region
|
|
||||||
(region-beginning) (region-end) "xsel -i -b")))
|
|
||||||
(error "Is program `xsel' installed?"))
|
|
||||||
(t
|
|
||||||
(when (display-graphic-p)
|
|
||||||
(call-interactively 'clipboard-kill-ring-save))
|
|
||||||
(message "Yanked region to X-clipboard")
|
|
||||||
(deactivate-mark))))
|
|
||||||
|
|
||||||
(defun cut-to-xclipboard(arg)
|
|
||||||
(interactive "P")
|
|
||||||
(cond
|
|
||||||
((not (use-region-p))
|
|
||||||
(message "Nothing to yank to X-clipboard"))
|
|
||||||
((and (not (display-graphic-p))
|
|
||||||
(/= 0 (shell-command-on-region
|
|
||||||
(region-beginning) (region-end) "xsel -i -b")))
|
|
||||||
(error "Is program `xsel' installed?"))
|
|
||||||
(t
|
|
||||||
(when (display-graphic-p)
|
|
||||||
(call-interactively 'clipboard-kill-ring-save))
|
|
||||||
(message "Yanked region to X-clipboard")
|
|
||||||
(kill-region (region-beginning) (region-end))
|
|
||||||
(deactivate-mark))))
|
|
||||||
|
|
||||||
(defun paste-from-xclipboard()
|
|
||||||
"Uses shell command `xsel -o' to paste from x-clipboard. With
|
|
||||||
one prefix arg, pastes from X-PRIMARY, and with two prefix args,
|
|
||||||
pastes from X-SECONDARY."
|
|
||||||
(interactive)
|
|
||||||
(if (display-graphic-p)
|
|
||||||
(clipboard-yank)
|
|
||||||
(let*
|
|
||||||
((opt (prefix-numeric-value current-prefix-arg))
|
|
||||||
(opt (cond
|
|
||||||
((= 1 opt) "b")
|
|
||||||
((= 4 opt) "p")
|
|
||||||
((= 16 opt) "s"))))
|
|
||||||
(insert (shell-command-to-string (concat "xsel -o -" opt))))))
|
|
||||||
|
|
||||||
(defun back-to-indentation-or-beginning ()
|
|
||||||
"Go back to indentation, if at indentation go to beginning of line"
|
|
||||||
(interactive)
|
|
||||||
(if (= (point) (progn (back-to-indentation) (point)))
|
|
||||||
(beginning-of-line)))
|
|
||||||
|
|
||||||
(defun transparent-terminal ()
|
|
||||||
(unless (display-graphic-p (selected-frame))
|
|
||||||
(set-face-background 'default "unspecified-bg" (selected-frame))))
|
|
||||||
|
|
||||||
(menu-bar-mode -1)
|
|
||||||
|
|
||||||
(ac-config-default)
|
|
||||||
|
|
||||||
(add-hook 'python-mode-hook 'anaconda-mode)
|
|
||||||
(add-hook 'python-mode-hook 'anaconda-eldoc-mode)
|
|
||||||
|
|
||||||
(require 'tex)
|
|
||||||
(require 'auto-complete-auctex)
|
|
||||||
(setq TeX-auto-save t)
|
|
||||||
(setq TeX-parse-self t)
|
|
||||||
(setq-default TeX-master nil)
|
|
||||||
|
|
||||||
(require 'ox-twbs)
|
|
||||||
|
|
||||||
(add-hook 'org-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(delete '("\\.pdf\\'" . default) org-file-apps)
|
|
||||||
(add-to-list 'org-file-apps '("\\.pdf\\'" . "evince %s"))))
|
|
||||||
|
|
||||||
(add-hook 'org-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(setq org-src-fontify-natively t)))
|
|
||||||
|
|
||||||
(add-hook 'org-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(setq org-pretty-entities t)))
|
|
||||||
|
|
||||||
(add-hook 'org-mode-hook 'rainbow-delimiters-mode)
|
|
||||||
|
|
||||||
(counsel-mode 1)
|
|
||||||
(global-set-key "\C-s" 'swiper)
|
|
||||||
|
|
||||||
(require 'paren)
|
|
||||||
(setq show-paren-style 'parenthesis)
|
|
||||||
(show-paren-mode 1)
|
|
||||||
|
|
||||||
(global-hl-line-mode 1)
|
|
||||||
(set-face-background 'hl-line "#141b1e")
|
|
||||||
(set-face-foreground 'highlight nil)
|
|
||||||
|
|
||||||
(require 'yasnippet)
|
|
||||||
(setq yas-snippet-dirs
|
|
||||||
'("~/.emacs.d/snippets/"))
|
|
||||||
(yas-global-mode 1)
|
|
||||||
|
|
||||||
(defvar my-keys-minor-mode-map
|
|
||||||
(let ((map (make-sparse-keymap)))
|
|
||||||
(define-key map (kbd "C-a") 'back-to-indentation-or-beginning)
|
|
||||||
(define-key map (kbd "C-c M-w") 'copy-to-xclipboard)
|
|
||||||
(define-key map (kbd "C-c C-w") 'cut-to-xclipboard)
|
|
||||||
(define-key map (kbd "C-c M-y") 'paste-from-xclipboard)
|
|
||||||
map)
|
|
||||||
"my-keys-minor-mode keymap.")
|
|
||||||
|
|
||||||
(define-minor-mode my-keys-minor-mode
|
|
||||||
"A minor mode so that my key settings override annoying major modes."
|
|
||||||
:init-value t
|
|
||||||
:lighter " my-keys")
|
|
||||||
|
|
||||||
(my-keys-minor-mode 1)
|
|
||||||
|
|
||||||
(add-hook 'conf-mode 'rainbow-mode)
|
|
|
@ -173,8 +173,6 @@ Using Anaconda-mode as default python development mode
|
||||||
Some default settings for LaTeX-Mode.
|
Some default settings for LaTeX-Mode.
|
||||||
AucTeX is needed.
|
AucTeX is needed.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'tex)
|
|
||||||
(require 'auto-complete-auctex)
|
|
||||||
(setq TeX-auto-save t)
|
(setq TeX-auto-save t)
|
||||||
(setq TeX-parse-self t)
|
(setq TeX-parse-self t)
|
||||||
(setq-default TeX-master nil)
|
(setq-default TeX-master nil)
|
||||||
|
@ -182,7 +180,7 @@ AucTeX is needed.
|
||||||
** Org
|
** Org
|
||||||
Enable a Twitter Bootstrap mode as an export mode for Org-mode.
|
Enable a Twitter Bootstrap mode as an export mode for Org-mode.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'ox-twbs)
|
;; (require 'ox-twbs)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Use Evince as default pdf viewer.
|
Use Evince as default pdf viewer.
|
||||||
|
@ -212,6 +210,24 @@ Add rainbow-delimiters in org-mode
|
||||||
(add-hook 'org-mode-hook 'rainbow-delimiters-mode)
|
(add-hook 'org-mode-hook 'rainbow-delimiters-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
Handy shortcuts
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(define-key global-map "\C-ca" 'org-agenda)
|
||||||
|
(define-key global-map "\C-cl" 'org-store-link)
|
||||||
|
(setq org-log-done t)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Enabled languages:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(org-babel-do-load-languages
|
||||||
|
'org-babel-load-languages
|
||||||
|
'( (python . t)
|
||||||
|
(sh . t)
|
||||||
|
(emacs-lisp . t)
|
||||||
|
(C . t)
|
||||||
|
))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Ivy/Counsel/Swiper
|
** Ivy/Counsel/Swiper
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(counsel-mode 1)
|
(counsel-mode 1)
|
||||||
|
@ -219,7 +235,7 @@ Add rainbow-delimiters in org-mode
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Parenthesis
|
** Parenthesis
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'paren)
|
;; (require 'paren)
|
||||||
(setq show-paren-style 'parenthesis)
|
(setq show-paren-style 'parenthesis)
|
||||||
(show-paren-mode 1)
|
(show-paren-mode 1)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
@ -232,7 +248,7 @@ Globaly highlight the current line in a slightly darker shade of grey.
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Yasnippet
|
** Yasnippet
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(require 'yasnippet)
|
;; (require 'yasnippet)
|
||||||
(setq yas-snippet-dirs
|
(setq yas-snippet-dirs
|
||||||
'("~/.emacs.d/snippets/"))
|
'("~/.emacs.d/snippets/"))
|
||||||
(yas-global-mode 1)
|
(yas-global-mode 1)
|
||||||
|
|
|
@ -1,17 +1,2 @@
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
(org-babel-load-file "~/.emacs.d/config.org")
|
(org-babel-load-file "~/.emacs.d/config.org")
|
||||||
(custom-set-variables
|
|
||||||
;; custom-set-variables was added by Custom.
|
|
||||||
;; 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.
|
|
||||||
'(org-agenda-files (quote ("~/Nextcloud/orgs/man.org")))
|
|
||||||
'(package-selected-packages
|
|
||||||
(quote
|
|
||||||
(auto-complete-auctex auto-complete counsel swiper material-theme anaconda-mode rainbow-mode ox-twbs google-this auctex smartparens eclim flycheck rainbow-delimiters forest-blue-theme))))
|
|
||||||
(custom-set-faces
|
|
||||||
;; custom-set-faces was added by Custom.
|
|
||||||
;; 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.
|
|
||||||
)
|
|
||||||
|
|
|
@ -5,26 +5,27 @@ from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def screenshot():
|
def screenshot():
|
||||||
os.system('import -window root /tmp/i3lock.png')
|
ss_time = time.time()
|
||||||
|
os.system('scrot /tmp/i3lock.png')
|
||||||
|
print('Screenshot: {}'.format(time.time() - ss_time))
|
||||||
|
|
||||||
|
|
||||||
def pixelate():
|
def pixelate():
|
||||||
|
pxl_time = time.time()
|
||||||
pixelSize = 12
|
pixelSize = 12
|
||||||
|
|
||||||
image = Image.open('/tmp/i3lock.png')
|
image = Image.open('/tmp/i3lock.png')
|
||||||
image_x = image.size[0]
|
|
||||||
image_y = image.size[1]
|
|
||||||
|
|
||||||
image = image.resize((int(image_x / pixelSize), int(image_y / pixelSize)),
|
image_x, image_y = image.size
|
||||||
Image.NEAREST)
|
|
||||||
|
|
||||||
image_x = image.size[0]
|
image = image.resize((int(image_x / pixelSize), int(image_y / pixelSize)), Image.NEAREST)
|
||||||
image_y = image.size[1]
|
image_x, image_y = image.size
|
||||||
|
|
||||||
image = image.resize((image_x * pixelSize, image_y * pixelSize),
|
image = image.resize((image_x * pixelSize, image_y * pixelSize),
|
||||||
Image.NEAREST)
|
Image.NEAREST)
|
||||||
|
|
||||||
image.save('/tmp/i3lock.png')
|
image.save('/tmp/i3lock.png')
|
||||||
|
print('pixelate: {}'.format(time.time() - pxl_time))
|
||||||
|
|
||||||
|
|
||||||
def getResolution():
|
def getResolution():
|
||||||
|
@ -34,7 +35,7 @@ def getResolution():
|
||||||
|
|
||||||
def lock_config():
|
def lock_config():
|
||||||
'Generation of a customized lock command'
|
'Generation of a customized lock command'
|
||||||
|
lock_time = time.time()
|
||||||
# constants
|
# constants
|
||||||
lock_core = 'i3lock'
|
lock_core = 'i3lock'
|
||||||
default_fontsize = 32
|
default_fontsize = 32
|
||||||
|
@ -60,13 +61,13 @@ def lock_config():
|
||||||
# time
|
# time
|
||||||
lock_time_pos = '--timepos="{}:{}"'.format(clock_x, clock_y)
|
lock_time_pos = '--timepos="{}:{}"'.format(clock_x, clock_y)
|
||||||
lock_time_size = '--timesize={}'.format(default_fontsize * 2)
|
lock_time_size = '--timesize={}'.format(default_fontsize * 2)
|
||||||
time = "{} {}".format(lock_time_pos, lock_time_size)
|
l_time = "{} {}".format(lock_time_pos, lock_time_size)
|
||||||
# date
|
# date
|
||||||
lock_date_pos = '--datepos="{}:{}"'.format(date_x, date_y)
|
lock_date_pos = '--datepos="{}:{}"'.format(date_x, date_y)
|
||||||
lock_date_size = '--datesize={}'.format(default_fontsize)
|
lock_date_size = '--datesize={}'.format(default_fontsize)
|
||||||
date = "{} {}".format(lock_date_pos, lock_date_size)
|
date = "{} {}".format(lock_date_pos, lock_date_size)
|
||||||
# done
|
# done
|
||||||
datetime = "{} {}".format(time, date)
|
datetime = "{} {}".format(l_time, date)
|
||||||
|
|
||||||
# Indicator config
|
# Indicator config
|
||||||
# Indicator inner
|
# Indicator inner
|
||||||
|
@ -102,6 +103,7 @@ def lock_config():
|
||||||
# background
|
# background
|
||||||
lock_pic = '-i /tmp/i3lock.png'
|
lock_pic = '-i /tmp/i3lock.png'
|
||||||
|
|
||||||
|
print('pixelate: {}'.format(time.time() - lock_time))
|
||||||
return "{} {} {} {} {}".format(lock_core, clock, datetime, indicator,
|
return "{} {} {} {} {}".format(lock_core, clock, datetime, indicator,
|
||||||
lock_pic)
|
lock_pic)
|
||||||
|
|
||||||
|
@ -132,9 +134,6 @@ def log(start_time):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
screenshot()
|
screenshot()
|
||||||
|
|
||||||
pixelate()
|
pixelate()
|
||||||
|
|
||||||
lock()
|
lock()
|
||||||
|
|
||||||
log(start_time)
|
log(start_time)
|
||||||
|
|
|
@ -1,32 +1 @@
|
||||||
appdirs==1.4.3
|
|
||||||
autopep8==1.3.3
|
|
||||||
chardet==3.0.4
|
|
||||||
cupshelpers==1.0
|
|
||||||
flake8==3.5.0
|
|
||||||
gufw==17.10.0
|
|
||||||
idna==2.6
|
|
||||||
jedi==0.11.1
|
|
||||||
lightdm-gtk-greeter-settings==1.2.2
|
|
||||||
louis==3.4.0
|
|
||||||
mccabe==0.6.1
|
|
||||||
npyscreen==4.10.5
|
|
||||||
packaging==16.8
|
|
||||||
pacman-mirrors==4.7.0
|
|
||||||
parso==0.1.1
|
|
||||||
Pillow==5.0.0
|
Pillow==5.0.0
|
||||||
pycairo==1.15.4
|
|
||||||
pycodestyle==2.3.1
|
|
||||||
pycups==1.9.73
|
|
||||||
pycurl==7.43.0.1
|
|
||||||
pyflakes==1.6.0
|
|
||||||
pygobject==3.26.1
|
|
||||||
pyparsing==2.2.0
|
|
||||||
ranger==1.8.1
|
|
||||||
requests==2.18.4
|
|
||||||
rope==0.10.7
|
|
||||||
six==1.11.0
|
|
||||||
speedtest-cli==1.0.7
|
|
||||||
syslogng==1.0
|
|
||||||
team==1.0
|
|
||||||
urllib3==1.22
|
|
||||||
yapf==0.20.0
|
|
||||||
|
|
Loading…
Reference in New Issue