blob: cdc2c7ed49f8b0f8393fad27d45307feb12a5bf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
;;; -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(defun bd/set-frame-alpha (value)
"Sets the transparency of the frame background. 0=transparent/100=opaque."
(interactive "nTransparency Value (30 - 100 opaque): ")
(setq value (max 30 (min value 100)))
(set-frame-parameter (selected-frame) 'alpha `(,value . ,value))
(message "Alpha set to %d" value))
(defun bd/set-bg (&optional arg)
"Set the current wallpaper using feh.
ARG can be one of the following:
- nil: set the most recent wallpaper
- directory: set a random image from the directory
- file: set the specified file"
(interactive "f")
(let ((wall (expand-file-name "~/wf/wall/current")))
(when arg
(cond
((file-regular-p arg) (copy-file arg wall t))
((file-directory-p arg)
(let* ((images (f-files arg (lambda (f) (string-match-p "\\.jpeg\\'" f))))
(rfile (nth (random (length images)) images)))
(and rfile (copy-file rfile wall t))))))
(start-process "set wallpaper" nil "feh" "--bg-fill" wall)
(message "Set wallpaper.")))
(defun bd/lock ()
"Lock the screen."
(interactive)
(start-process "lock" nil "slock"))
(defun bd/shoot-full ()
"Take a full-screen screenshot."
(interactive)
(let ((default-directory (xdg-user-dir "PICTURES")))
(start-process-shell-command "flameshot" nil "flameshot full")))
(defun bd/shoot-part ()
"Take a selective screen screenshot."
(interactive)
(let ((default-directory (xdg-user-dir "PICTURES")))
(start-process-shell-command "flameshot" nil "flameshot launcher")))
(defun bd/toggle-mute ()
"Toggle between muted and unmuted."
(interactive)
(start-process "sound toggle" nil "pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle"))
(defun bd/set-volume (value)
"Sets the volume to VALUE."
(start-process "set volume" nil "pactl" "set-sink-volume" "@DEFAULT_SINK@" value))
(defun bd/decrement-volume ()
"Decrements the volume."
(interactive)
(bd/set-volume "-4%"))
(defun bd/increment-volume ()
"Increments the volume."
(interactive)
(bd/set-volume "+4%"))
(defun bd/set-brightness (value)
"Sets the brightness to VALUE."
(start-process "set brightness" nil "brightnessctl" "set" value))
(defun bd/decrement-brightness ()
"decrements the brightness."
(interactive)
(bd/set-brightness "5%-"))
(defun bd/increment-brightness ()
"Increments the brightness."
(interactive)
(bd/set-brightness "5%+"))
(defun bd/get-directory-dwim ()
"Returns the directory you always wanted."
(or (when (project-current)
(project-root (project-current))) ;; git
(locate-dominating-file "." "Makefile") ;; make
(locate-dominating-file "." "manifest.scm") ;; guix
default-directory))
(defun bd/buffer-exwm-p (buf)
"Return non-nil if BUF is an `exwm-mode' buffer."
(member
(buffer-local-value 'major-mode (get-buffer buf))
'(exwm-mode)))
(defun bd/buffer-scratch-p (buf)
"Return non-nil if BUF is a scratch buffer."
(buffer-local-value 'scratch-buffer (get-buffer buf)))
(defun bd/buffer-text-p (buf)
"Return non-nil if BUF derives from `text-mode'."
(provided-mode-derived-p (buffer-local-value 'major-mode (get-buffer buf)) 'text-mode))
(defun bd/buffer-prog-p (buf)
"Return non-nil if BUF derives from `prog-mode'."
(provided-mode-derived-p (buffer-local-value 'major-mode (get-buffer buf)) 'prog-mode))
(defun bd/buffer-dired-p (buf)
"Return non-nil if BUF is a `dired-mode' buffer."
(member
(buffer-local-value 'major-mode (get-buffer buf))
'(dired-mode)))
(defun bd/buffer-irc-p (buf)
"Return non-nil if BUF is an `irc-mode' buffer."
(member
(buffer-local-value 'major-mode (get-buffer buf))
'(rcirc-mode erc-mode)))
(defun bd/buffer-ordinary-p (buf)
"Return non-nil if BUF does not fit into known categories."
(not (or (bd/buffer-exwm-p buf)
(bd/buffer-text-p buf)
(bd/buffer-prog-p buf)
(bd/buffer-scratch-p buf)
(bd/buffer-dired-p buf)
(bd/buffer-irc-p buf))))
(provide 'bd--utility)
;;; bd--utility.el ends here
|