linux.el 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ;;; linuxFunctions --- functions for linux systems
  2. ;;; Commentary:
  3. ;;; Functions that only work on linux systems.
  4. ;;; Code:
  5. (setq output-dir "~/Desktop/") ;make sure to have the '/' at the end
  6. (defun browse-url-seamonkey-new-tab (url &optional new-window)
  7. ;; new-window ignored
  8. "Open URL in a new tab in Seamonkey."
  9. (interactive (browse-url-interactive-arg "URL: "))
  10. (unless
  11. (string= ""
  12. (shell-command-to-string
  13. (concat "seamonkey -remote 'openURL(" url ",new-tab)'")))
  14. (message "Starting Seamonkey...")
  15. (start-process (concat "seamonkey " url) nil "seamonkey" url)
  16. (message "Starting Seamonkey...done")))
  17. (defun eww-external-browser-seamonkey (&optional url)
  18. "Open *eww* webpage in external browser. URL won't be used."
  19. (interactive)
  20. (eww-copy-page-url)
  21. (browse-url-seamonkey-new-tab (car kill-ring)))
  22. ;; jul-mode stuff
  23. ;(add-to-list 'load-path "~/jul-mode")
  24. ;(load "jul-mode.el")
  25. (defun youtube-dl-video (url)
  26. "Easily download youtube videos in Emacs!
  27. Pass it the URL of the video you wish to download. Then it will
  28. place the full youtube-dl command in your kill ring. Yank this
  29. to an eshell buffer or something."
  30. (interactive "sURL: ")
  31. (kill-append (concat "youtube-dl --output " output-dir
  32. "\%\(title\)s.\%\(ext\)s ")
  33. t))
  34. (defun youtube-dl-ogg (url)
  35. "Easily download youtube videos in Emacs!
  36. Pass it the URL of the video you wish to convert to ogg and
  37. download. Then it will place the full youtube-dl command in
  38. your kill ring. Yank this to an eshell buffer or something."
  39. (interactive "sURL: ")
  40. (kill-append (concat "youtube-dl -x --audio-format vorbis "
  41. "--output " output-dir
  42. "\%\(title\)s.\%\(ext\)s ")
  43. t))
  44. (defun screen-shot (delay-time)
  45. "Easily take a screenshot your screen.
  46. DELAY-TIME will specify how long until the screenshot is taken."
  47. (interactive "sDelay Time:")
  48. (shell-command (concat "scrot -d " delay-time))
  49. (shell-command (concat "mv *_scrot.png " output-dir)))
  50. (defun screen-select ()
  51. "Easily take a screenshot of a cursor selected area."
  52. (interactive)
  53. (shell-command (concat "scrot -s"))
  54. (shell-command (concat "mv *_scrot.png " output-dir)))
  55. (defun screen-record ()
  56. "Easily record your screen!"
  57. (interactive)
  58. (async-shell-command (concat "avconv -f alsa -ac 1 -i hw:1 -f x11grab -r 25 "
  59. "-s 1920x1080 -i :0.0 -vcodec libx264 -threads 4 "
  60. output-dir "screen-capture.mkv")))
  61. ;; Allows me to see the battery level and status on my Chromebook
  62. ;; Maybe one day I'll add it to the mode line
  63. (defun battery-level ()
  64. (interactive)
  65. (let (charge-now charge-full status)
  66. (with-temp-buffer
  67. (insert-file-contents "/sys/class/power_supply/sbs-20-000b/charge_now")
  68. (goto-char (point-min))
  69. (kill-line)
  70. (setq charge-now (car kill-ring))
  71. (insert-file-contents "/sys/class/power_supply/sbs-20-000b/charge_full")
  72. (goto-char (point-min))
  73. (kill-line)
  74. (setq charge-full (car kill-ring))
  75. (insert-file-contents "/sys/class/power_supply/sbs-20-000b/status")
  76. (goto-char (point-min))
  77. (kill-line)
  78. (setq status (car kill-ring)))
  79. (setq charge-now (concat charge-now ".0")) ;make it a float
  80. (setq charge-full (concat charge-full ".0")) ;make it a float
  81. (message "%s, %s"
  82. (* 100 (/ (string-to-number charge-now)
  83. (string-to-number charge-full)))
  84. status)))
  85. (global-set-key (kbd "M-<f1>") 'battery-level)
  86. (provide 'linux)
  87. ;;; linux.el ends here