summaryrefslogtreecommitdiff
path: root/sysutil.sh
blob: 3bf6946e3aa70caaa15ce0e0d16fdbf6fe48f720 (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
#!/bin/bash

XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}

function prepsound() {
    tDIR=$XDG_CACHE_HOME/stoggle

    if [ ! -d $tDIR ]; then
        mkdir -p $tDIR || exit 1
    fi
    sDIR=/usr/share/sounds/freedesktop/stereo
}

function playsound() {
    if [ ! $sDIR ]; then
        echo Warning: Sound directory not set, setting to default
        prepsound
    fi
    pw-play $sDIR/$1 || paplay $sDIR/$1
}

function getSound() {
    prepsound
    if [ -f $tDIR/$1 ]; then
        return 1
    else
        return 0
    fi
}

function setSound() {
    prepsound

    if [ ! -d $sDIR ]; then
        mkdir -p $sDIR || exit 1
    fi
    if [ -f $sDIR/$1 ]; then
        rm $sDIR/$1
    else
        touch $sDIR/$1
    fi
}

# if $(getSound screenshot); then
    # echo "Screenshot sound is enabled"
# else
    # echo "Screenshot sound is disabled"
# fi

function screenshot() {
    $HOME/scripts/hyprshot $@
}

if [ "$1" ]; then
    $@
fi