aboutsummaryrefslogtreecommitdiff
path: root/nixos/flake/home/scripts.nix.org
blob: b98b3899700a323fb7b0990f3627dc1b4abd4a13 (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
#+title: Custom Scripts

Open script container.
#+begin_src nix :tangle ~/.flake/home/scripts.nix :mkdirp yes
  { config, pkgs, ... }:

  {
    home.file = {
#+end_src

Use =fuzzel= to open a menu to power off, reboot, or log out.
#+begin_src nix :tangle ~/.flake/home/scripts.nix :mkdirp yes
      ".local/bin/poweroptions.sh" = {
        text = ''
    #!/bin/sh

    getoption () {
        fuzzel --dmenu -l 3 -x 1 -r 10 << EOF
            󰐥 power off
            󰜉 restart
            󰍃 logout
    EOF
    }

    option=$(getoption | xargs)
    case $option in
        '󰐥 power off')
            systemctl poweroff;;
        '󰜉 restart')
            systemctl reboot;;
        '󰍃 logout')
            hyprctl dispatch exit;;
    esac
        '';
        executable = true;
      };
#+end_src

Close script container.
#+begin_src nix :tangle ~/.flake/home/scripts.nix :mkdirp yes
    };
  }
#+end_src