summaryrefslogtreecommitdiff
path: root/README.adoc
blob: f2c71978446eead567d4d8148e405458d86b200e (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
= My shell scripts
:toc:

These are the shell scripts I've written for a broad range of tasks.
Move these into your $PATH to call them without needing to provide a full path to the script to run it.


== General

=== battery-notify

This script monitors battery levels for 2 battery systems and sends notifications via `notify-send` when the battery gets too low.
At 5% the script notifies the user that the computer will lock in 60 seconds if not plugged in.
If the computer isn't plugged in within 60 seconds, the screen locks with the command defined in the `lock_command` variable on line 3.

=== pdf2png

This script converts PDF pages to compressed PNG images.
It is useful for sending to cell phones or other situations where a PDF might be cumbersome.
The script also adds a 2 pixel, black border to the PNGs, which can be helpful for displaying them on white backgrounds.

This script accepts up to 3 arguments:

. The PDF to convert to PNG
. The first page to convert
. The last page to convert

The full command can be

`pdf2png example.pdf 1 5`

If argument 3 is empty, the script only converts the page given in argument 2.

`pdf2png example.pdf 1` 

If only the pdf name is given, the script only creates a PNG of the first page.

`pdf2png example.pdf`


*Dependencies*

* pdftoppm
* imagemagick
* optipng



== Dmenu Scripts (dm-*)

These are the scripts that I pipe through https://tools.suckless.org/dmenu[dmenu] to perform various tasks.


=== dm-mylinks

I use this for storing my links to my different websites or contact information.
This reads a file stored in $HOME/.config/mylinks/links.txt for links or whatever information you want to store in it.
Upon selecting the desired line in dmenu, the script types the link out wherever your cursor was when you launched the script.

This is is an example structure for the `links.txt` file:

[source]
----
My website https://example.com
My github https://example.com
My email address example@example.com
----

Selecting the `My email address example@example.com` line in dmenu will simply output `example@example.com` at the cursor's current location.

Create the needed directory and file with `mkdir -p $HOME/.config/mylinks && touch $HOME/.config/mylinks/links.txt`
Add all links and their descriptions to the `links.txt` file with the link as the last item in each string (with a space before it).


*Dependencies:*

* dmenu
* xdotool
* https://tools.suckless.org/dmenu/patches/fuzzymatch/[dmenu fuzzymatch patch]

Removing the `-F` flag from the `dm="dmenu -i -l 15 -F"` line removes the dependency on the fuzzymatch patch.


=== dm-nightlight

This lets me change my screen's color temperature for evenings or mornings.
The script uses the program _redshift_ to lessen blue light, and emit a warmer light that isn't as harsh or disruptive to sleep. 

Redshift can perform these temperature changes automatically, but I prefer to adjust this manually through this script.

*Dependencies*:

* redshift
* https://tools.suckless.org/dmenu/patches/center/[dmenu center patch]

Removing the `-c` flag from `dm="dmenu -i -c -l 10"` removes the dependency on the center patch.


=== dm-screenshot

This screenshot script allows me to screenshot my entire screen, a specific area, or open the most recent screenshot I took.
This saves screenshots with a filename format that matches Android phones, should you want to sync phone and computer screenshots in one directory in chronological order.

*Dependencies*:

* imagemagick
* xdg-user-dirs (read more about the spec https://wiki.archlinux.org/title/XDG_user_directories[here])
* https://tools.suckless.org/dmenu/patches/center/[dmenu center patch]

Removing the `-c` flag from `dm="dmenu -i -c -l 10"` removes the dependency on the center patch.


== Status bar scripts (sb-*)

These status bar scripts use the https://fontawesome.com/v5/search?m=free[free FontAwesome Icons].
These scripts work for status bar programs like DWMBlocks, Polybar, or can be called in an `xsetroot` command.


=== sb-battery

Displays a single, averaged battery percentage for laptops with two batteries.


=== sb-hdspace

Displays the space available on a single hard drive.
Users may have to adjust the row and column that the script reads from, depending on their system configuration. 


=== sb-ram

Displays the amount of random access memory (RAM) the system is currently using.


=== sb-time

Displays the current date in IS0-8601 (YYYY-MM-DD) format, and the current time in 24-hour (HH:MM) format.


=== sb-volume

Displays the current volume from the system's default PulseAudio sink.


=== sb-wifi

Displays the the system's current wifi connection status.
Do note that this just displays the system's connection with the wifi access point, and not the access point's connection to the internet (this script can show an active wifi status while not connected to the internet).


=== Using these scripts in a status bar

*DWMBlocks* blocks.h config

[source,C]
----
static const Block blocks[] = {
        /*Icon*/        /*Command*/     /*Update Interval*/     /*Update Signal*/
        {"", 		"sb-wifi", 	2, 			0},
        {"", 		"sb-volume", 	2, 			0},
        {"", 		"sb-ram",  	2, 			0},
        {"", 		"sb-hdspace", 	360, 			0},
        {"", 		"sb-time", 	15, 			0},
        {"", 		"sb-battery", 	1, 			0},
};

//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " ";
static unsigned int delimLen = 5;
----

*Polybar* config for calling a single module, on the right side of the status bar.
Find these areas in the config file and change them as needed.

[source,shell]
----
font-0 = Source Code Pro:pixelsize=10;1
font-1 = Font Awesome 5 Free:size=10;1
font-2 = Font Awesome 5 Free Solid:size=10;1
font-3 = Font Awesome 5 Free Brands:size=10;1
font-4 = siji:pixelsize=10;1

modules-right = sb-ram

[module/sb-ram]
type = custom/script
format-foreground = ${colors.foreground}
format-prefix = ""
format-padding = 1
label = "%output%"
initial = 1
interval = 3
exec = change/this/to/the/path/to/this/script
----