blob: 31e60fbe3df247ec4c0bceed01ccb0858e0bf94c (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
{
config,
}: rec {
pkgs = (import ../pkgs.nix).stable {};
pkgs2305 = (import ../pkgs.nix).stable2305 {};
xorgInnerEnv = pkgs.buildEnv {
name = "xorg-inner-env";
paths = [
pkgs.xorg.xorgserver
(pkgs.runCommand "xorg-conf-inner" {} ''
mkdir -p "$out"/share/X11/xorg.conf.d/
cp ${./xorg.conf} "$out"/share/X11/xorg.conf.d/99-loadout.conf
'')
] ++ (
config.awesome.xorgInputDrivers pkgs
);
};
xorgConf = pkgs.runCommand "xorg-conf" {} ''
cat >>"$out" <<EOF
Section "Files"
ModulePath "${xorgInnerEnv}/lib/xorg/modules"
EndSection
${config.awesome.xorgConfExtra}
EOF
for f in $(ls ${xorgInnerEnv}/share/X11/xorg.conf.d | sort); do
cat ${xorgInnerEnv}/share/X11/xorg.conf.d/"$f" >> "$out"
done
'';
# nativeWrap is used for apps which are not installed via nix which don't play
# nicely with it.
nativeWrap = pkgs.writeScriptBin "native-wrap" ''
#!${pkgs.bash}/bin/bash
unset XDG_CONFIG_DIRS
unset XDG_DATA_DIRS
unset GDK_PIXBUF_MODULE_FILE
exec "$@"
'';
wp = ../wallpapers;
startupAppsLua = builtins.toString (
builtins.map (a: ''"${a}",'') config.awesome.startupApps
);
configLua = pkgs.writeTextDir "config.lua" ''
home_dir = os.getenv("HOME").."/"
bin_dir = "${./bin}/"
share_dir = "${./share}/"
wp_dir = "${wp}/"
startupApps = { ${startupAppsLua} }
'';
# awesomeInner is what is started up by startx, within an X session.
awesomeInner = pkgs.writeScript "awesome" ''
#!${pkgs.bash}/bin/bash
set -e -x
# Turn off powersaving (fuck the environment)
${pkgs.xorg.xset}/bin/xset -dpms
${pkgs.xorg.xset}/bin/xset s off
# HACK: This sleep is here because phwmon actually creates a separate tray
# icon for each thing it monitors, and if the process runs at the same time
# as another process which creates a tray icon they can get interleaved.
(sleep 5 && phwmon.py) &
############################################################################
# Init awesome
data_dir="$HOME/.local/share/awesome";
mkdir -p "$data_dir"
log_dir="$data_dir"/logs
mkdir -p $log_dir
# only keep last N awesome.log files
ls "$log_dir" | sort -n | head -n -5 | while read f; do rm "$log_dir"/"$f"; done
############################################################################
# Exec
this_log=$log_dir/awesome.$(date '+%Y%m%d.%H%M%S').log
echo "New awesome session starting" > $this_log
exec ${pkgs.awesome}/bin/awesome \
-c ${./rc.lua} \
--search ${configLua} \
--search ${./share} \
--search ${pkgs.awesome}/share/awesome/themes \
2>&1 2>>$this_log
'';
awesome = pkgs.writeShellScriptBin "awesome" ''
export XORGCONFIG=${xorgConf}
exec startx ${awesomeInner}
'';
env = pkgs.buildEnv {
name = "awesome-env";
paths = [
pkgs.tela-icon-theme
# We only include utilities in here which are directly used by awesome.
# General purpose applications go in the root default.nix env.
pkgs.xorg.xinit
pkgs.scrot
pkgs.feh
pkgs.brightnessctl
pkgs.cbatticon
pkgs.phwmon
xorgInnerEnv
nativeWrap
awesome
];
};
}
|