aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/aliases/system.zsh
blob: 047c4bf06d4b27ee857571d5a577436bc689bd87 (plain) (blame)
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
alias copy="xclip -selection clipboard -i";

alias update="sudo nixos-rebuild switch --upgrade";
alias auto-remove="sudo nix-collect-garbage -d";
alias clean-boot-entries="sudo /run/current-system/bin/switch-to-configuration boot";

alias rebuild="sudo nixos-rebuild switch";
alias list-gens="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";

nix-rollback() {
  [[ -z "$1" ]] && echo "Specify generation number: nix-rollback 330" && return 1;
  sudo nixos-rebuild switch --rollback=$1;
}

nixlsversions() {
  if [ -z "$1" ]; then
    echo "Specify package name";
    return 1;
  fi;
  curl "https://www.nixhub.io/packages/$1?_data=routes%2F_nixhub.packages.%24pkg._index" | jq '.releases | map([.version, .platforms[0].commit_hash, .platforms[0].attribute_path])'
}

#alias mirrorlist-refresh="sudo reflector --latest 200 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist-arch"

# Sandbox
#alias sandbox="sudo ~/scripts/host-file-elb-update.sh";

# Runit helpers
#sv_enable() { [[ -f "/etc/runit/sv/$1" ]] && sudo ln -s /etc/runit/sv/$1 /run/runit/service; }
#sv_disable() { sudo unlink /run/runit/service/$1; }

setup_webcam_day() {
  v4l2-ctl -d /dev/video2 \
    --set-ctrl brightness=1 \
    --set-ctrl contrast=13 \
    --set-ctrl saturation=15 \
    --set-ctrl gamma=150 \
    --set-ctrl gain=70 \
    --set-ctrl sharpness=3 \
    --set-ctrl exposure_time_absolute=400;
}

setup_webcam_night() {
  v4l2-ctl -d /dev/video2 \
    --set-ctrl brightness=2 \
    --set-ctrl contrast=12 \
    --set-ctrl saturation=13 \
    --set-ctrl gamma=160 \
    --set-ctrl gain=70 \
    --set-ctrl sharpness=2 \
    --set-ctrl exposure_time_absolute=520;
}

# Run a program with limited memory
limit_memory() {
  local lim=${1:-100M}; shift 1;
  systemd-run --user --scope -p MemoryHigh="$lim" -p MemorySwapMax="$lim" "$@";
}

# KDE connect aliases
phone() {
  local device=$(kdeconnect-cli -a --id-only)
  if [ -z "$device" ]; then
    echo "Device not found"
    return 1
  fi
  kdeconnect-cli --device "$device" "$@"
}
phone_file() { phone --share "$@"; }
phone_text() { phone --share-text "$@"; }