-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.lua
72 lines (60 loc) · 2.01 KB
/
helpers.lua
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
-- ===================================================================
-- Helper functions and tables that don't fit anywhere else.
-- ===================================================================
local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful")
-- Module table.
local helpers = {}
helpers.default_apps = {
terminal = "kitty",
editor = os.getenv("EDITOR") or "vim"
}
-- Sets a wallpaper on each screen.
function helpers.set_wallpaper(s)
-- Wallpaper
if beautiful.wallpaper then
local wallpaper = beautiful.wallpaper
-- If wallpaper is a function, call it with the screen
if type(wallpaper) == "function" then
wallpaper = wallpaper(s)
end
gears.wallpaper.maximized(wallpaper, s, true)
end
end
-- Activate screen locker.
function helpers.lock_screen()
awful.util.spawn("xscreensaver-command -lock")
end
-- Toggle system volume mute.
function helpers.toggle_mute()
awful.util.spawn("pulsemixer --toggle-mute")
end
-- Change system volume.
-- @param change_percentage_text Amount to change, preceded by +/- (e.g. "+5")
function helpers.change_volume(change_percentage_text)
awful.util.spawn("pulsemixer --change-volume " .. change_percentage_text)
end
-- Play/pause music player.
function helpers.song_toggle_play()
awful.util.spawn("playerctl play-pause --player=spotify")
end
-- Go to previous song in music player.
function helpers.song_previous()
awful.util.spawn("playerctl previous --player=spotify")
end
-- Go to next song in music player.
function helpers.song_next()
awful.util.spawn("playerctl next --player=spotify")
end
-- Go to next song in music player.
function helpers.song_next()
awful.util.spawn("playerctl next --player=spotify")
end
-- Toggle desk light on/off.
function helpers.toggle_desk_light()
awful.util.spawn_with_shell(
"curl -X POST \"https://api.lifx.com/v1/lights/label:PC/toggle\" -H \"Authorization: Bearer $(<~/.lifxtoken)\""
)
end
return helpers