Too many changes
This commit is contained in:
parent
96e0778c53
commit
606b0bac65
@ -2,21 +2,29 @@
|
||||
# programs.adb.enable = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
(vivaldi.override { proprietaryCodecs = true; })
|
||||
# Important
|
||||
rxvt_unicode
|
||||
wget
|
||||
curl
|
||||
xfce4-14.thunar
|
||||
xfce4-14.xfce4-taskmanager
|
||||
xclip
|
||||
bc
|
||||
|
||||
lxqt.pavucontrol-qt
|
||||
git
|
||||
# Other
|
||||
(vivaldi.override { proprietaryCodecs = true; })
|
||||
wget
|
||||
gparted
|
||||
neofetch
|
||||
pavucontrol
|
||||
bashmount
|
||||
p7zip
|
||||
zip
|
||||
ranger
|
||||
xfce4-14.thunar
|
||||
xfce4-14.xfce4-taskmanager
|
||||
xclip
|
||||
git
|
||||
] ++ lib.optionals config.deviceSpecific.isLaptop [
|
||||
# Important
|
||||
acpi
|
||||
light
|
||||
];
|
||||
|
||||
home-manager.users.alukard.home.packages = with pkgs; [
|
||||
|
@ -9,14 +9,14 @@
|
||||
# ./applications/okular.nix
|
||||
# ./applications/weechat.nix
|
||||
# ./applications/spectral.nix
|
||||
# ./workspace/i3blocks
|
||||
./workspace/i3blocks
|
||||
./workspace/i3
|
||||
./workspace/zsh.nix
|
||||
./workspace/gtk.nix
|
||||
./workspace/compton.nix
|
||||
./workspace/misc.nix
|
||||
./workspace/dunst.nix
|
||||
# ./workspace/kde
|
||||
./workspace/kde
|
||||
# ./workspace/synergy.nix
|
||||
# ./workspace/ssh.nix
|
||||
./workspace/locale.nix
|
||||
|
@ -12,9 +12,11 @@ with types; {
|
||||
devInfo = config.devices.${config.device};
|
||||
in rec {
|
||||
isLaptop = (!isNull (builtins.match ".*Laptop" device));
|
||||
# smallScreen = (device == "Prestigio-Laptop");
|
||||
isVM = (!isNull (builtins.match ".*VM" device));
|
||||
smallScreen = (device == "Dell-Laptop");
|
||||
isShared = devInfo.isShared;
|
||||
cpu = devInfo.cpu.vendor;
|
||||
video = devInfo.video;
|
||||
isSSD = devInfo.drive.type == "ssd";
|
||||
hostName = if !isNull devInfo.hostName then
|
||||
devInfo.hostName
|
||||
@ -37,6 +39,7 @@ with types; {
|
||||
type = "ssd";
|
||||
size = 250;
|
||||
};
|
||||
video = "amd";
|
||||
ram = 16;
|
||||
isShared = false;
|
||||
hostName = "ataraxia-pc";
|
||||
@ -51,6 +54,7 @@ with types; {
|
||||
type = "hdd";
|
||||
size = 500;
|
||||
};
|
||||
video = "nvidia";
|
||||
ram = 6;
|
||||
isShared = true;
|
||||
hostName = null;
|
||||
@ -65,6 +69,7 @@ with types; {
|
||||
type = "ssd";
|
||||
size = 250;
|
||||
};
|
||||
video = "intel";
|
||||
ram = 8;
|
||||
isShared = true;
|
||||
hostName = "dell-ataraxia";
|
||||
@ -79,6 +84,7 @@ with types; {
|
||||
type = "ssd";
|
||||
size = 12;
|
||||
};
|
||||
video = "virtualbox";
|
||||
ram = 4;
|
||||
isShared = false;
|
||||
hostName = null;
|
||||
|
@ -2,11 +2,11 @@
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
options = if config.deviceSpecific.isSSD then
|
||||
[ "discard" "ssd" "noatime" "compress=zstd" ]
|
||||
[ "ssd" "noatime" "compress=zstd" ]
|
||||
else
|
||||
[ "discard" "noatime" "compress=zstd" ];
|
||||
[ "noatime" "compress=zstd" ];
|
||||
};
|
||||
"/shared" = {
|
||||
"/shared" = lib.mkIf config.deviceSpecific.isVM {
|
||||
fsType = "vboxsf";
|
||||
device = "shared";
|
||||
options = [ "rw" "nodev" "relatime" "iocharset=utf8" "uid=1000" "gid=100" "dmode=0770" "fmode=0770" "nofail" ];
|
||||
|
@ -5,11 +5,23 @@ with rec {
|
||||
with deviceSpecific; {
|
||||
|
||||
hardware.cpu.${devices.${device}.cpu.vendor}.updateMicrocode = true; # Update microcode
|
||||
# hardware.enableRedistributableFirmware = true; # For some unfree drivers
|
||||
hardware.enableRedistributableFirmware = true; # For some unfree drivers
|
||||
|
||||
hardware.opengl.enable = true;
|
||||
hardware.opengl.driSupport = true;
|
||||
hardware.opengl.driSupport32Bit = true; # For steam
|
||||
# Enable hardware video acceleration
|
||||
nixpkgs.config.packageOverrides = pkgs: {
|
||||
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
|
||||
};
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
extraPackages = if video == "intel" then [
|
||||
pkgs.vaapiIntel
|
||||
pkgs.vaapiVdpau
|
||||
pkgs.libvdpau-va-gl
|
||||
pkgs.intel-media-driver
|
||||
] else [ ];
|
||||
};
|
||||
|
||||
hardware.bluetooth.enable = isLaptop;
|
||||
|
||||
@ -18,12 +30,12 @@ with deviceSpecific; {
|
||||
systemd-boot.enable = true;
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
kernelPackages = if config.virtualisation.virtualbox.guest.enable == false then
|
||||
pkgs.linuxPackages_latest
|
||||
kernelPackages = if isVM then
|
||||
pkgs.linuxPackages
|
||||
else
|
||||
pkgs.linuxPackages;
|
||||
pkgs.linuxPackages_latest;
|
||||
supportedFilesystems = [ "ntfs" ];
|
||||
extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ];
|
||||
# extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ];
|
||||
};
|
||||
|
||||
sound.enable = true;
|
||||
@ -33,4 +45,14 @@ with deviceSpecific; {
|
||||
support32Bit = true;
|
||||
# systemWide = true;
|
||||
};
|
||||
|
||||
# SSD Section
|
||||
boot.kernel.sysctl = {
|
||||
"vm.swappiness" = if isSSD then 1 else 10;
|
||||
};
|
||||
services.fstrim = {
|
||||
enable = isSSD;
|
||||
interval = "weekly";
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
networking = {
|
||||
networkmanager.enable = false;
|
||||
wireless = {
|
||||
enable = config.device != "AMD-Workstation";
|
||||
enable = config.deviceSpecific.isLaptop;
|
||||
# driver = "wext";
|
||||
networks.Alukard_5GHz = {
|
||||
pskRaw = "feee27000fb0d7118d498d4d867416d04d1d9a1a7b5dbdbd888060bbde816fe4";
|
||||
|
@ -14,42 +14,27 @@ with deviceSpecific; {
|
||||
pkgs.systemd
|
||||
}/bin/systemctl start ac"
|
||||
ACTION=="add|change", SUBSYSTEM=="backlight", MODE:="0777"
|
||||
'' + (if device == "ASUS-Laptop" then ''
|
||||
ACTION=="add|change", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="${
|
||||
pkgs.iw
|
||||
}/bin/iw dev %k set power_save off"
|
||||
'' else
|
||||
"")
|
||||
else
|
||||
"";
|
||||
'' else "";
|
||||
systemd.services.battery = {
|
||||
enable = isLaptop;
|
||||
description = "Executes commands needed on battery power";
|
||||
script = ''
|
||||
${
|
||||
pkgs.linuxPackages_latest.cpupower
|
||||
}/bin/cpupower frequency-set -g powersave
|
||||
${pkgs.hdparm}/bin/hdparm -B 1 /dev/sda
|
||||
echo "500" > /sys/class/backlight/*/brightness
|
||||
'';
|
||||
script =
|
||||
''
|
||||
${pkgs.linuxPackages_latest.cpupower}/bin/cpupower frequency-set -g powersave
|
||||
echo "500" > /sys/class/backlight/*/brightness
|
||||
'' + (if !isSSD then ''
|
||||
${pkgs.hdparm}/bin/hdparm -B 1 /dev/sda
|
||||
'' else "");
|
||||
};
|
||||
systemd.services.ac = {
|
||||
enable = isLaptop;
|
||||
description = "Executes commands needed on ac power";
|
||||
script = ''
|
||||
${
|
||||
pkgs.linuxPackages_latest.cpupower
|
||||
}/bin/cpupower frequency-set -g performance
|
||||
${pkgs.hdparm}/bin/hdparm -B 255 /dev/sda
|
||||
echo "900" > /sys/class/backlight/*/brightness
|
||||
'';
|
||||
};
|
||||
systemd.services.leds_setup = {
|
||||
enable = (device == "ASUS-Laptop");
|
||||
description = "Set up leds triggers";
|
||||
wantedBy = ["multi-user.target"];
|
||||
script = ''
|
||||
echo "phy0rx" > /sys/class/leds/asus-wireless\:\:airplane/trigger
|
||||
'';
|
||||
script =
|
||||
''
|
||||
${pkgs.linuxPackages_latest.cpupower}/bin/cpupower frequency-set -g performance
|
||||
echo "900" > /sys/class/backlight/*/brightness
|
||||
'' + (if !isSSD then ''
|
||||
${pkgs.hdparm}/bin/hdparm -B 255 /dev/sda
|
||||
'' else "");
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
# users.defaultUser = "alukard";
|
||||
|
||||
security.apparmor.enable = true;
|
||||
programs.firejail.enable = true;
|
||||
@ -18,21 +17,22 @@
|
||||
"pulse"
|
||||
# "adbusers"
|
||||
"input"
|
||||
# "libvirtd"
|
||||
"vboxusers"
|
||||
# "wireshark"
|
||||
];
|
||||
description = "Дмитрий Холкин";
|
||||
uid = 1000;
|
||||
hashedPassword = "$6$kDBGyd99tto$9LjQwixa7NYB9Kaey002MD94zHob1MmNbVz9kx3yX6Q4AmVgsFMGUyNuHozXprxyuXHIbOlTcf8nd4rK8MWfI/";
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
# security.sudo = {
|
||||
# enable = true;
|
||||
# extraConfig = ''
|
||||
# alukard ALL = (root) NOPASSWD: /run/current-system/sw/bin/nixos-rebuild switch
|
||||
# '';
|
||||
# };
|
||||
security.sudo = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
ALL ALL = (ALL) NOPASSWD: /run/current-system/sw/bin/btrfs fi usage *
|
||||
'';
|
||||
# extraConfig = ''
|
||||
# alukard ALL = (root) NOPASSWD: /run/current-system/sw/bin/nixos-rebuild switch
|
||||
# '';
|
||||
};
|
||||
# nix.requireSignedBinaryCaches = false;
|
||||
|
||||
home-manager.useUserPackages = true;
|
||||
|
@ -12,6 +12,7 @@
|
||||
noto-fonts-emoji
|
||||
hasklig
|
||||
powerline-fonts
|
||||
material-icons
|
||||
];
|
||||
fontconfig = {
|
||||
enable = true;
|
||||
|
97
modules/workspace/i3blocks/default.nix
Normal file
97
modules/workspace/i3blocks/default.nix
Normal file
@ -0,0 +1,97 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
with import ../../../support.nix { inherit pkgs config lib; };
|
||||
let scripts = import ./scripts pkgs config;
|
||||
in {
|
||||
home-manager.users.alukard.xsession.windowManager.i3.extraConfig = ''
|
||||
bar {
|
||||
id top
|
||||
font pango:Material Icons 11, Roboto Mono 11
|
||||
mode dock
|
||||
hidden_state hide
|
||||
position top
|
||||
status_command ${pkgs.i3blocks}/bin/i3blocks
|
||||
workspace_buttons yes
|
||||
strip_workspace_numbers no
|
||||
tray_output none
|
||||
colors {
|
||||
background ${config.themes.colors.bg}
|
||||
statusline ${config.themes.colors.fg}
|
||||
separator ${config.themes.colors.alt}
|
||||
focused_workspace ${config.themes.colors.bg} ${config.themes.colors.bg} ${config.themes.colors.blue}
|
||||
active_workspace ${config.themes.colors.bg} ${config.themes.colors.bg} ${config.themes.colors.green}
|
||||
inactive_workspace ${config.themes.colors.bg} ${config.themes.colors.bg} ${config.themes.colors.fg}
|
||||
urgent_workspace ${config.themes.colors.bg} ${config.themes.colors.bg} ${config.themes.colors.orange}
|
||||
binding_mode ${config.themes.colors.bg} ${config.themes.colors.bg} ${config.themes.colors.yellow}
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
||||
home-manager.users.alukard.xdg.configFile."i3blocks/config".text = ''
|
||||
interval=60
|
||||
markup=pango
|
||||
'' + genIni {
|
||||
a_email = if !isNull config.secrets.gmail or null then {
|
||||
command = scripts.email;
|
||||
} else
|
||||
{ };
|
||||
b_weather = {
|
||||
command = scripts.weather;
|
||||
interval = 600;
|
||||
};
|
||||
d_sound = {
|
||||
command = scripts.sound;
|
||||
interval = 1;
|
||||
};
|
||||
# e_music = {
|
||||
# command = scripts.music;
|
||||
# interval = 1;
|
||||
# };
|
||||
f_battery = pkgs.stdenv.lib.optionalAttrs config.deviceSpecific.isLaptop {
|
||||
command = scripts.battery;
|
||||
};
|
||||
g_brightness = pkgs.stdenv.lib.optionalAttrs config.deviceSpecific.isLaptop {
|
||||
command = scripts.brightness;
|
||||
interval = 1;
|
||||
};
|
||||
h_wireless = pkgs.stdenv.lib.optionalAttrs config.networking.wireless.enable {
|
||||
command = scripts.wireless;
|
||||
};
|
||||
# i_network = {
|
||||
# command = scripts.network;
|
||||
# };
|
||||
j_cpuload = {
|
||||
command = ''
|
||||
echo '<span font="Material Icons 11">cached</span>' $(top -b -n1 -p 1 | fgrep "Cpu(s)" | tail -1 | awk -F'id,' -v prefix="$prefix" '{ split($1, vs, ","); v=vs[length(vs)]; sub("%", "", v); printf "%s%.1f%%\n", prefix, 100 - v }')
|
||||
'';
|
||||
interval = 3;
|
||||
};
|
||||
k_cpufreq = {
|
||||
command = ''
|
||||
echo '<span font="Material Icons 11">flash_on</span>' $(${pkgs.bc}/bin/bc <<< "$(lscpu | grep "MHz" | awk '{print $3}')/1") MHz
|
||||
'';
|
||||
interval = 1;
|
||||
};
|
||||
# l_temperature = {
|
||||
# command = scripts.temperature;
|
||||
# };
|
||||
m_free = {
|
||||
command = ''
|
||||
echo '<span font="Material Icons 11">location_searching</span>' $(${pkgs.bc}/bin/bc <<< `free | tail -2 | head -1 | awk '{print "scale=2; "$7"/1048576"}'`)GiB
|
||||
'';
|
||||
# command = scripts.free;
|
||||
};
|
||||
n_df = {
|
||||
command = ''
|
||||
echo '<span font="Material Icons 11"></span>' $(sudo btrfs fi usage / | grep "Free" | awk '{print $3}')
|
||||
'';
|
||||
};
|
||||
o_date = {
|
||||
command = "${pkgs.coreutils}/bin/date +'<span font=\"Material Icons 11\"></span> %a %y-%m-%d'";
|
||||
interval = 10;
|
||||
};
|
||||
p_time = {
|
||||
command = "${pkgs.coreutils}/bin/date +'<span font=\"Material Icons 11\"></span> %T'";
|
||||
interval = 1;
|
||||
};
|
||||
};
|
||||
}
|
46
modules/workspace/i3blocks/scripts/battery.nix
Normal file
46
modules/workspace/i3blocks/scripts/battery.nix
Normal file
@ -0,0 +1,46 @@
|
||||
{ acpi, bash, iconfont, low_threshold ? 10, ... }: ''
|
||||
#!${bash}/bin/bash
|
||||
BATTERY="`${acpi}/bin/acpi -b | grep --invert-match unavailable | head -1`"
|
||||
STATUS=`awk -F'[,:] ' '{print $2}' <<< "$BATTERY"`
|
||||
CHARGE=`awk -F'[,%] ' '{print $2}' <<< "$BATTERY" | tr -d "%"`
|
||||
TIME=`awk -F', ' '{print $3}' <<< "$BATTERY" | cut -d " " -f 1`
|
||||
case "$STATUS" in
|
||||
Full) ;& "Not charging") icon=; text="FULL"; status=0
|
||||
;;
|
||||
Charging)
|
||||
text="$CHARGE% ($TIME)"
|
||||
status=0
|
||||
case $CHARGE in
|
||||
[2-3]*) icon=;;
|
||||
[4-5]*) icon=;;
|
||||
[6-7]*) icon=;;
|
||||
[8-9]*|100) icon=;;
|
||||
*) icon=;;
|
||||
esac
|
||||
;;
|
||||
Discharging)
|
||||
if [[ $CHARGE -gt ${toString low_threshold} ]]
|
||||
then
|
||||
status=0
|
||||
else
|
||||
status=33
|
||||
fi
|
||||
text="$CHARGE% ($TIME)";
|
||||
case $CHARGE in
|
||||
1?) icon=;;
|
||||
2?) icon=;;
|
||||
3?) icon=;;
|
||||
4?) icon=;;
|
||||
5?) icon=;;
|
||||
6?) icon=;;
|
||||
7?) icon=;;
|
||||
8?) icon=;;
|
||||
9?) icon=;;
|
||||
100) icon=;;
|
||||
*) icon=;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
echo "<span font=\"${iconfont}\">$icon</span> $text"
|
||||
exit $status
|
||||
''
|
19
modules/workspace/i3blocks/scripts/brightness.nix
Normal file
19
modules/workspace/i3blocks/scripts/brightness.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ iconfont, light, config, ... }: ''
|
||||
case $BLOCK_BUTTON in
|
||||
4) sudo ${light}/bin/light -A 5;;
|
||||
5) sudo ${light}/bin/light -U 5;;
|
||||
esac
|
||||
LIGHT=`${light}/bin/light | cut -f 1 -d '.'`
|
||||
if [[ $LIGHT -lt 33 ]]
|
||||
then
|
||||
icon=
|
||||
else
|
||||
if [[ $LIGHT -lt 66 ]]
|
||||
then
|
||||
icon=
|
||||
else
|
||||
icon=
|
||||
fi
|
||||
fi
|
||||
echo "<span font='${iconfont}'>$icon</span> $LIGHT"
|
||||
''
|
35
modules/workspace/i3blocks/scripts/default.nix
Normal file
35
modules/workspace/i3blocks/scripts/default.nix
Normal file
@ -0,0 +1,35 @@
|
||||
p: c:
|
||||
with p;
|
||||
builtins.mapAttrs (name: value:
|
||||
stdenv.mkDerivation {
|
||||
name = "free";
|
||||
src = value;
|
||||
unpackPhase = "true";
|
||||
buildInputs = [ghc];
|
||||
buildPhase = "ghc -o $out $src";
|
||||
installPhase = "true";
|
||||
}) {
|
||||
free = ./free.hs;
|
||||
temperature = ./temperature.hs;
|
||||
network = ./network.hs;
|
||||
} // builtins.mapAttrs (name: value:
|
||||
writeTextFile {
|
||||
inherit name;
|
||||
text = callPackage value {
|
||||
iconfont = "Material Icons 11";
|
||||
config = c;
|
||||
};
|
||||
executable = true;
|
||||
checkPhase =
|
||||
"${bash}/bin/bash -n $src || ${python3}/bin/python3 -m compileall $src";
|
||||
}) {
|
||||
battery = ./battery.nix;
|
||||
brightness = ./brightness.nix;
|
||||
email = ./email.nix;
|
||||
wireless = ./wireless.nix;
|
||||
weather = ./weather.nix;
|
||||
sound = ./sound.nix;
|
||||
music = ./music.nix;
|
||||
#temperature = ./temperature.nix;
|
||||
#free = ./free.nix;
|
||||
}
|
10
modules/workspace/i3blocks/scripts/email.nix
Normal file
10
modules/workspace/i3blocks/scripts/email.nix
Normal file
@ -0,0 +1,10 @@
|
||||
{ python3, iconfont, config, ... }: ''
|
||||
#!${python3}/bin/python3
|
||||
import imaplib
|
||||
obj = imaplib.IMAP4_SSL('imap.gmail.com', 993)
|
||||
obj.login("${config.secrets.gmail.user}", "${config.secrets.gmail.password}")
|
||||
obj.select()
|
||||
l = len(obj.search(None, 'unseen')[1][0].split())
|
||||
print('<span font="${iconfont}"></span> %s' % str(l))
|
||||
exit(33 if l != 0 else 0)
|
||||
''
|
10
modules/workspace/i3blocks/scripts/free.hs
Normal file
10
modules/workspace/i3blocks/scripts/free.hs
Normal file
@ -0,0 +1,10 @@
|
||||
import System.Exit
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
freeMemory <- read
|
||||
<$> (!!1) <$> words
|
||||
<$> (!!2) <$> lines
|
||||
<$> readFile "/proc/meminfo"
|
||||
putStr $ (take 5 $ show $ freeMemory / 1048576) ++ "GiB"
|
||||
exitWith $ if freeMemory > 500000 then ExitSuccess else ExitFailure 33
|
19
modules/workspace/i3blocks/scripts/music.nix
Normal file
19
modules/workspace/i3blocks/scripts/music.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ python3, playerctl, iconfont, ...}: ''
|
||||
#!${python3}/bin/python
|
||||
from subprocess import getoutput, call
|
||||
from os import environ
|
||||
status = getoutput("${playerctl}/bin/playerctl status")
|
||||
if "BLOCK_BUTTON" in environ:
|
||||
BLOCK_BUTTON = environ["BLOCK_BUTTON"]
|
||||
if BLOCK_BUTTON == "1": call(["${playerctl}/bin/playerctl", "play-pause"])
|
||||
if BLOCK_BUTTON == "2": call(["${playerctl}/bin/playerctl", "stop"])
|
||||
if BLOCK_BUTTON == "3": call(["${playerctl}/bin/playerctl", "next"])
|
||||
if status == "Paused":
|
||||
icon=""
|
||||
elif status == "Playing":
|
||||
icon=""
|
||||
else:
|
||||
icon = ""
|
||||
text = getoutput("${playerctl}/bin/playerctl metadata title")[:20:]
|
||||
print("<span font='${iconfont}'>%s</span> %s" % (icon, text))
|
||||
''
|
40
modules/workspace/i3blocks/scripts/network.hs
Normal file
40
modules/workspace/i3blocks/scripts/network.hs
Normal file
@ -0,0 +1,40 @@
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Monad (mapM)
|
||||
import System.Directory (listDirectory)
|
||||
|
||||
path :: String
|
||||
path = "/sys/class/net/"
|
||||
|
||||
data Statistics = Statistics !Float !Float
|
||||
|
||||
instance Semigroup Statistics where
|
||||
Statistics a b <> Statistics c d = Statistics (a + c) (b + d)
|
||||
|
||||
instance Monoid Statistics where
|
||||
mempty = Statistics 0 0
|
||||
|
||||
icon :: String -> String
|
||||
icon i = "<span font='Material Icons 11'>" ++ i ++ "</span>"
|
||||
|
||||
readInterface :: FilePath -> IO Statistics
|
||||
readInterface interface = do
|
||||
rx <- read <$> readFile (path ++ interface ++ "/statistics/rx_bytes")
|
||||
tx <- read <$> readFile (path ++ interface ++ "/statistics/tx_bytes")
|
||||
return $ Statistics rx tx
|
||||
|
||||
readInterfaces :: [FilePath] -> IO Statistics
|
||||
readInterfaces interfaces = mconcat <$> (mapM readInterface interfaces)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
interfaces <- listDirectory path
|
||||
Statistics rx tx <- readInterfaces interfaces
|
||||
threadDelay 1000000
|
||||
Statistics rx' tx' <- readInterfaces interfaces
|
||||
putStrLn
|
||||
$ (icon "\58052")
|
||||
++ show (round $(rx' - rx)/1000) ++ "kBps "
|
||||
++ (icon "\58054")
|
||||
++ show (round $(tx' - tx)/1000) ++ "kBps"
|
32
modules/workspace/i3blocks/scripts/sound.nix
Normal file
32
modules/workspace/i3blocks/scripts/sound.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ pamixer, lxqt, iconfont, ... }: ''
|
||||
case $BLOCK_BUTTON in
|
||||
1) ${pamixer}/bin/pamixer -t;;
|
||||
3) ${lxqt.pavucontrol-qt}/bin/pavucontrol-qt & ;;
|
||||
4) ${pamixer}/bin/pamixer -i 5;;
|
||||
5) ${pamixer}/bin/pamixer -d 5;;
|
||||
esac
|
||||
code=0
|
||||
if [[ `${pamixer}/bin/pamixer --get-mute` = "true" ]]
|
||||
then
|
||||
volume=""
|
||||
end=""
|
||||
icon=""
|
||||
else
|
||||
volume=`${pamixer}/bin/pamixer --get-volume`
|
||||
end="%"
|
||||
if [[ $volume -lt 33 ]]
|
||||
then
|
||||
icon=""
|
||||
else
|
||||
if [[ $volume -lt 66 ]]
|
||||
then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
code=33
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "<span font='${iconfont}'>$icon</span> $volume$end"
|
||||
exit $code
|
||||
''
|
47
modules/workspace/i3blocks/scripts/temperature.hs
Normal file
47
modules/workspace/i3blocks/scripts/temperature.hs
Normal file
@ -0,0 +1,47 @@
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
import Control.Monad (forM)
|
||||
import System.Posix.Files
|
||||
import Data.List (isPrefixOf, isInfixOf)
|
||||
import System.Exit
|
||||
|
||||
|
||||
|
||||
-- | Traverse from 'top' directory and return all the files by
|
||||
-- filtering with 'include' predicate.
|
||||
traverseDir :: FilePath -> (FilePath -> Bool) -> IO [FilePath]
|
||||
traverseDir top include = do
|
||||
ds <- getDirectoryContents top
|
||||
paths <- forM (filter include ds) $ \d -> do
|
||||
let path = top </> d
|
||||
s <- getFileStatus path
|
||||
if isDirectory s
|
||||
then traverseDir path include
|
||||
else return [path]
|
||||
return $ concat paths
|
||||
|
||||
|
||||
|
||||
-- | Get temperatures from hardware sensors in </sys/class/hwmon>
|
||||
getTemps :: IO [Int]
|
||||
getTemps = do
|
||||
hwmons <- traverseDir "/sys/class/hwmon"
|
||||
(
|
||||
\name
|
||||
-> ("hwmon" `isPrefixOf` name)
|
||||
|| ("temp" `isInfixOf` name) && ("input" `isInfixOf` name)
|
||||
)
|
||||
fmap (round .(/1000) . read) <$> traverse (readFile) hwmons
|
||||
|
||||
-- | Get a symbol corresponding to the temperature
|
||||
getSymbol :: Integral n => n -> String
|
||||
getSymbol t
|
||||
| t < 50 = "\57868" --
|
||||
| t < 80 = "\57866" --
|
||||
| otherwise = "\57867" --
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
maxTemp <- maximum <$> getTemps
|
||||
putStrLn $ (getSymbol <> show) maxTemp <> "°"
|
||||
exitWith $ if maxTemp < 80 then ExitSuccess else ExitFailure 33
|
6
modules/workspace/i3blocks/scripts/temperature.nix
Normal file
6
modules/workspace/i3blocks/scripts/temperature.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{ ... }:
|
||||
''
|
||||
temp=$((`cat /sys/class/thermal/thermal_zone*/temp | sort | tail -1`/1000))
|
||||
echo $temp °
|
||||
[[ $temp -gt 80 ]] && exit 33
|
||||
''
|
8
modules/workspace/i3blocks/scripts/weather.nix
Normal file
8
modules/workspace/i3blocks/scripts/weather.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{ bash, config, curl, ... }: ''
|
||||
#!${bash}/bin/bash
|
||||
${curl}/bin/curl wttr.in/Volzhskiy\?format=3 | awk -F": " '{print $2}'
|
||||
if [[ $BLOCK_BUTTON == 1 ]]
|
||||
then
|
||||
${config.defaultApplications.term.cmd} --hold -e "${curl}/bin/curl wttr.in"
|
||||
fi
|
||||
''
|
17
modules/workspace/i3blocks/scripts/wireless.nix
Normal file
17
modules/workspace/i3blocks/scripts/wireless.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{ bash, iw, wpa_supplicant_gui, iconfont, ... }: ''
|
||||
#!${bash}/bin/bash
|
||||
case $BLOCK_BUTTON in
|
||||
1) ${wpa_supplicant_gui}/bin/wpa_gui;;
|
||||
2) pkexec rfkill block wifi;;
|
||||
3) pkexec rfkill unblock wifi;;
|
||||
esac
|
||||
WIFI="`${iw}/bin/iw wlan0 info | grep ssid | cut -f2 -d' '`"
|
||||
if [[ `wc -c <<< "$WIFI"` -lt 2 ]]
|
||||
then
|
||||
echo "<span font='${iconfont}'></span>"
|
||||
exit 33
|
||||
else
|
||||
echo "<span font='${iconfont}'></span> $WIFI"
|
||||
exit 0
|
||||
fi
|
||||
''
|
128
modules/workspace/kde/default.nix
Normal file
128
modules/workspace/kde/default.nix
Normal file
@ -0,0 +1,128 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
with import ../../../support.nix { inherit lib config; }; {
|
||||
# services.flatpak.enable = true;
|
||||
# services.flatpak.extraPortals = [pkgs.plasma5.xdg-desktop-portal-kde];
|
||||
# services.dbus.packages =
|
||||
# [ pkgs.plasma5.xdg-desktop-portal-kde pkgs.flatpak pkgs.firefox pkgs.systemd ];
|
||||
# nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;
|
||||
# home-manager.users.alukard.home.packages = [pkgs.qt5ct];
|
||||
# environment.sessionVariables = {
|
||||
# DESKTOP_SESSION = "kde";
|
||||
# QT_XFT = "true";
|
||||
# QT_SELECT = "5";
|
||||
# XDG_CURRENT_DESKTOP = "KDE";
|
||||
# KDE_SESSION_VERSION = "5";
|
||||
# QT_SCALE_FACTOR = "1";
|
||||
# QT_AUTO_SCREEN_SCALE_FACTOR = "0";
|
||||
# GTK_USE_PORTAL = "1";
|
||||
# DE = "kde";
|
||||
# QT_QPA_PLATFORMTHEME="kde";
|
||||
# };
|
||||
home-manager.users.alukard.xdg.configFile."kdeglobals".text = genIni {
|
||||
"Colors:Button" = {
|
||||
BackgroundAlternate = thmDec.dark;
|
||||
BackgroundNormal = thmDec.bg;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.blue;
|
||||
ForegroundInactive = thmDec.alt;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.orange;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.gray;
|
||||
};
|
||||
"Colors:Complementary" = {
|
||||
BackgroundAlternate = thmDec.dark;
|
||||
BackgroundNormal = thmDec.bg;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.orange;
|
||||
ForegroundInactive = thmDec.alt;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.yellow;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.blue;
|
||||
};
|
||||
"Colors:Selection" = {
|
||||
BackgroundAlternate = thmDec.blue;
|
||||
BackgroundNormal = thmDec.blue;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.fg;
|
||||
ForegroundInactive = thmDec.fg;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.orange;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.alt;
|
||||
};
|
||||
"Colors:Tooltip" = {
|
||||
BackgroundAlternate = thmDec.dark;
|
||||
BackgroundNormal = thmDec.bg;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.blue;
|
||||
ForegroundInactive = thmDec.alt;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.orange;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.gray;
|
||||
};
|
||||
"Colors:View" = {
|
||||
BackgroundAlternate = thmDec.dark;
|
||||
BackgroundNormal = thmDec.bg;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.blue;
|
||||
ForegroundInactive = thmDec.alt;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.orange;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.gray;
|
||||
};
|
||||
"Colors:Window" = {
|
||||
BackgroundAlternate = thmDec.dark;
|
||||
BackgroundNormal = thmDec.bg;
|
||||
DecorationFocus = thmDec.blue;
|
||||
DecorationHover = thmDec.blue;
|
||||
ForegroundActive = thmDec.blue;
|
||||
ForegroundInactive = thmDec.alt;
|
||||
ForegroundLink = thmDec.blue;
|
||||
ForegroundNegative = thmDec.red;
|
||||
ForegroundNeutral = thmDec.orange;
|
||||
ForegroundNormal = thmDec.fg;
|
||||
ForegroundPositive = thmDec.green;
|
||||
ForegroundVisited = thmDec.gray;
|
||||
};
|
||||
General = {
|
||||
ColorScheme = "Generated";
|
||||
Name = "Generated";
|
||||
fixed = "Roboto Mono,11,-1,5,50,0,0,0,0,0";
|
||||
font = "Roboto,11,-1,5,50,0,0,0,0,0";
|
||||
menuFont = "Roboto,11,-1,5,50,0,0,0,0,0";
|
||||
shadeSortColumn = true;
|
||||
smallestReadableFont = "Roboto,8,-1,5,57,0,0,0,0,0,Medium";
|
||||
toolBarFont = "Roboto,11,-1,5,50,0,0,0,0,0";
|
||||
};
|
||||
KDE = {
|
||||
DoubleClickInterval = 400;
|
||||
ShowDeleteCommand = true;
|
||||
SingleClick = false;
|
||||
StartDragDist = 4;
|
||||
StartDragTime = 500;
|
||||
WheelScrollLines = 3;
|
||||
contrast = 4;
|
||||
widgetStyle = "Breeze";
|
||||
};
|
||||
Icons = { Theme = "Papirus-Dark"; };
|
||||
};
|
||||
}
|
@ -6,30 +6,7 @@
|
||||
x // {
|
||||
events = ["key"];
|
||||
attributes = ["exec"];
|
||||
}) ((if config.device == "ASUS-Laptop" then [
|
||||
{
|
||||
keys = [229];
|
||||
command =
|
||||
"expr -1 + `cat '/sys/class/leds/asus::kbd_backlight/brightness'` > '/sys/class/leds/asus::kbd_backlight/brightness'";
|
||||
}
|
||||
{
|
||||
keys = [230];
|
||||
command =
|
||||
"expr 1 + `cat '/sys/class/leds/asus::kbd_backlight/brightness'` > '/sys/class/leds/asus::kbd_backlight/brightness'";
|
||||
}
|
||||
{
|
||||
keys = [560];
|
||||
command = toString (pkgs.stdenv.mkDerivation {
|
||||
name = "als-script";
|
||||
src = ./als-script.hs;
|
||||
buildInputs = [pkgs.ghc];
|
||||
buildPhase = "ghc $src -o $out";
|
||||
unpackPhase = "true";
|
||||
installPhase = "true";
|
||||
});
|
||||
}
|
||||
] else
|
||||
[]) ++ [
|
||||
}) ([
|
||||
{
|
||||
keys = [225];
|
||||
command = "${pkgs.light}/bin/light -A 10";
|
||||
|
@ -1,24 +1,26 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
cpu = config.deviceSpecific.cpu;
|
||||
isShared = config.deviceSpecific.isShared;
|
||||
defaultUser = config.user.defaultUser;
|
||||
in {
|
||||
with rec {
|
||||
inherit (config) deviceSpecific;
|
||||
};
|
||||
with deviceSpecific; {
|
||||
services.xserver = {
|
||||
enable = true;
|
||||
# enableTCP = true;
|
||||
|
||||
libinput = {
|
||||
enable = true;
|
||||
enable = isLaptop;
|
||||
sendEventsMode = "disabled-on-external-mouse";
|
||||
middleEmulation = false;
|
||||
# naturalScrolling = true;
|
||||
};
|
||||
|
||||
videoDrivers = if cpu == "amd" then
|
||||
["amdgpu"]
|
||||
else if cpu == "intel" then
|
||||
["intel"]
|
||||
# TODO: make settings for laptops with dGPU
|
||||
videoDrivers = if video == "amd" then
|
||||
[ "amdgpu" ]
|
||||
else if video == "nvidia" then
|
||||
[ "nvidia" ]
|
||||
else if video == "intel" then
|
||||
[ "intel" ]
|
||||
else
|
||||
[ ];
|
||||
|
||||
@ -27,7 +29,6 @@ in {
|
||||
greeter.enable = isShared;
|
||||
autoLogin.enable = !isShared;
|
||||
autoLogin.user = "alukard";
|
||||
# autoLogin.user = defaultUser;
|
||||
};
|
||||
|
||||
# desktopManager.plasma5.enable = true;
|
||||
@ -44,7 +45,7 @@ in {
|
||||
xkbOptions = "grp:win_space_toggle";
|
||||
};
|
||||
|
||||
environment.systemPackages = if cpu == "amd" then
|
||||
environment.systemPackages = if video == "amd" then
|
||||
[ (pkgs.mesa.override { enableRadv = true; }) ]
|
||||
else
|
||||
[ ];
|
||||
|
Loading…
x
Reference in New Issue
Block a user