diff options
author | Akshay <[email protected]> | 2021-09-26 16:56:36 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-09-26 16:56:36 +0100 |
commit | 5cdb4e421a809de51c3ebe8404e50d732721238b (patch) | |
tree | 73b71617c41b3e13edbf26035e821bb884d30441 |
init
43 files changed, 2820 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1 @@ | |||
result | |||
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..83e07d2 --- /dev/null +++ b/flake.lock | |||
@@ -0,0 +1,157 @@ | |||
1 | { | ||
2 | "nodes": { | ||
3 | "flake-compat": { | ||
4 | "flake": false, | ||
5 | "locked": { | ||
6 | "lastModified": 1627913399, | ||
7 | "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", | ||
8 | "owner": "edolstra", | ||
9 | "repo": "flake-compat", | ||
10 | "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", | ||
11 | "type": "github" | ||
12 | }, | ||
13 | "original": { | ||
14 | "owner": "edolstra", | ||
15 | "repo": "flake-compat", | ||
16 | "type": "github" | ||
17 | } | ||
18 | }, | ||
19 | "flake-utils": { | ||
20 | "locked": { | ||
21 | "lastModified": 1629481132, | ||
22 | "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", | ||
23 | "owner": "numtide", | ||
24 | "repo": "flake-utils", | ||
25 | "rev": "997f7efcb746a9c140ce1f13c72263189225f482", | ||
26 | "type": "github" | ||
27 | }, | ||
28 | "original": { | ||
29 | "owner": "numtide", | ||
30 | "repo": "flake-utils", | ||
31 | "type": "github" | ||
32 | } | ||
33 | }, | ||
34 | "home-manager": { | ||
35 | "inputs": { | ||
36 | "nixpkgs": [ | ||
37 | "nixpkgs" | ||
38 | ] | ||
39 | }, | ||
40 | "locked": { | ||
41 | "lastModified": 1631573611, | ||
42 | "narHash": "sha256-u2E/wstadWNcn6vOIoK1xY86QPOzzBZQfT1FbePfdaI=", | ||
43 | "owner": "nix-community", | ||
44 | "repo": "home-manager", | ||
45 | "rev": "7d9ba15214004c979d2c8733f8be12ce6502cf8a", | ||
46 | "type": "github" | ||
47 | }, | ||
48 | "original": { | ||
49 | "owner": "nix-community", | ||
50 | "ref": "release-21.05", | ||
51 | "repo": "home-manager", | ||
52 | "type": "github" | ||
53 | } | ||
54 | }, | ||
55 | "neovim": { | ||
56 | "inputs": { | ||
57 | "flake-compat": "flake-compat", | ||
58 | "neovim-flake": "neovim-flake", | ||
59 | "nixpkgs": "nixpkgs" | ||
60 | }, | ||
61 | "locked": { | ||
62 | "lastModified": 1632643930, | ||
63 | "narHash": "sha256-7MGPPBLI/E8D+wLBBA+9AmZQ6O2JqMuCR9SDIEHHm7g=", | ||
64 | "owner": "nix-community", | ||
65 | "repo": "neovim-nightly-overlay", | ||
66 | "rev": "2abb3014b87c0b63bb30be4e199c7bf280d05807", | ||
67 | "type": "github" | ||
68 | }, | ||
69 | "original": { | ||
70 | "owner": "nix-community", | ||
71 | "repo": "neovim-nightly-overlay", | ||
72 | "type": "github" | ||
73 | } | ||
74 | }, | ||
75 | "neovim-flake": { | ||
76 | "inputs": { | ||
77 | "flake-utils": "flake-utils", | ||
78 | "nixpkgs": [ | ||
79 | "neovim", | ||
80 | "nixpkgs" | ||
81 | ] | ||
82 | }, | ||
83 | "locked": { | ||
84 | "dir": "contrib", | ||
85 | "lastModified": 1632620331, | ||
86 | "narHash": "sha256-6KqtlHdteNmeaPez9egvYebcytvT7PcGkIQ2giSNOEQ=", | ||
87 | "owner": "neovim", | ||
88 | "repo": "neovim", | ||
89 | "rev": "b3b02eb52943fdc8ba74af3b485e9d11655bc9c9", | ||
90 | "type": "github" | ||
91 | }, | ||
92 | "original": { | ||
93 | "dir": "contrib", | ||
94 | "owner": "neovim", | ||
95 | "repo": "neovim", | ||
96 | "type": "github" | ||
97 | } | ||
98 | }, | ||
99 | "nixos-hardware": { | ||
100 | "locked": { | ||
101 | "lastModified": 1632267580, | ||
102 | "narHash": "sha256-AvNXdmaPHYs6idbfgu1H40vEw4Wq15xLAgCnpCN1l1A=", | ||
103 | "owner": "nixos", | ||
104 | "repo": "nixos-hardware", | ||
105 | "rev": "3cc8c47af31798040ea62499090540413279f832", | ||
106 | "type": "github" | ||
107 | }, | ||
108 | "original": { | ||
109 | "owner": "nixos", | ||
110 | "repo": "nixos-hardware", | ||
111 | "type": "github" | ||
112 | } | ||
113 | }, | ||
114 | "nixpkgs": { | ||
115 | "locked": { | ||
116 | "lastModified": 1632411313, | ||
117 | "narHash": "sha256-lekODc44lVo9/0EwGiX6LoEt2KhiPdcfNopealMJ7n4=", | ||
118 | "owner": "nixos", | ||
119 | "repo": "nixpkgs", | ||
120 | "rev": "51bcdc4cdaac48535dabf0ad4642a66774c609ed", | ||
121 | "type": "github" | ||
122 | }, | ||
123 | "original": { | ||
124 | "owner": "nixos", | ||
125 | "ref": "nixos-unstable", | ||
126 | "repo": "nixpkgs", | ||
127 | "type": "github" | ||
128 | } | ||
129 | }, | ||
130 | "nixpkgs_2": { | ||
131 | "locked": { | ||
132 | "lastModified": 1632639184, | ||
133 | "narHash": "sha256-fRLxre+gPxIkjFVj17O68pyAWU1cxT20XFOiulIWzRw=", | ||
134 | "owner": "NixOS", | ||
135 | "repo": "nixpkgs", | ||
136 | "rev": "fd8a7fd07da0f3fc0e27575891f45c2f88e5dd44", | ||
137 | "type": "github" | ||
138 | }, | ||
139 | "original": { | ||
140 | "owner": "NixOS", | ||
141 | "ref": "nixos-21.05", | ||
142 | "repo": "nixpkgs", | ||
143 | "type": "github" | ||
144 | } | ||
145 | }, | ||
146 | "root": { | ||
147 | "inputs": { | ||
148 | "home-manager": "home-manager", | ||
149 | "neovim": "neovim", | ||
150 | "nixos-hardware": "nixos-hardware", | ||
151 | "nixpkgs": "nixpkgs_2" | ||
152 | } | ||
153 | } | ||
154 | }, | ||
155 | "root": "root", | ||
156 | "version": 7 | ||
157 | } | ||
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..330ca03 --- /dev/null +++ b/flake.nix | |||
@@ -0,0 +1,52 @@ | |||
1 | { | ||
2 | description = "nerdypepper's nixos config"; | ||
3 | |||
4 | inputs = { | ||
5 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; | ||
6 | nixos-hardware.url = "github:nixos/nixos-hardware"; | ||
7 | home-manager = { | ||
8 | url = "github:nix-community/home-manager/release-21.05"; | ||
9 | inputs.nixpkgs.follows = "nixpkgs"; | ||
10 | }; | ||
11 | neovim.url = "github:nix-community/neovim-nightly-overlay"; | ||
12 | }; | ||
13 | |||
14 | outputs = | ||
15 | { self | ||
16 | , nixpkgs | ||
17 | , nixos-hardware | ||
18 | , home-manager | ||
19 | , neovim | ||
20 | , ... | ||
21 | } @ inputs: { | ||
22 | |||
23 | overlays = { | ||
24 | nvim-nightly = neovim.overlay; | ||
25 | }; | ||
26 | |||
27 | nixosConfigurations = { | ||
28 | olive = nixpkgs.lib.nixosSystem { | ||
29 | system = "x86_64-linux"; | ||
30 | modules = [ | ||
31 | { | ||
32 | imports = [ ./hosts/olive/configuration.nix ]; | ||
33 | _module.args.self = self; | ||
34 | } | ||
35 | home-manager.nixosModules.home-manager | ||
36 | { | ||
37 | home-manager.useGlobalPkgs = true; | ||
38 | home-manager.useUserPackages = true; | ||
39 | home-manager.users.np = { | ||
40 | imports = [ ./home.nix ]; | ||
41 | _module.args.self = self; | ||
42 | _module.args.inputs = inputs; | ||
43 | _module.args.theme = import ./theme.nix; | ||
44 | }; | ||
45 | } | ||
46 | ]; | ||
47 | }; | ||
48 | }; | ||
49 | |||
50 | }; | ||
51 | |||
52 | } | ||
diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..93f66ad --- /dev/null +++ b/home.nix | |||
@@ -0,0 +1,88 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | |||
9 | imports = [ | ||
10 | ./programs | ||
11 | ./services | ||
12 | # ./scripts | ||
13 | ./x | ||
14 | ./mail.nix | ||
15 | ]; | ||
16 | |||
17 | home.stateVersion = "21.05"; | ||
18 | home.username = "np"; | ||
19 | home.homeDirectory = "/home/np"; | ||
20 | home.packages = with pkgs; [ | ||
21 | |||
22 | vim | ||
23 | unzip | ||
24 | curl | ||
25 | tmux | ||
26 | weechat | ||
27 | rofi | ||
28 | firefox | ||
29 | xclip | ||
30 | ripgrep | ||
31 | ccls | ||
32 | miniserve | ||
33 | rnix-lsp | ||
34 | pfetch | ||
35 | st | ||
36 | arandr | ||
37 | imagemagick | ||
38 | ffmpeg | ||
39 | maim | ||
40 | wget | ||
41 | cmus | ||
42 | tree | ||
43 | rxvt-unicode | ||
44 | neomutt | ||
45 | mpv | ||
46 | nodePackages.bash-language-server | ||
47 | gitAndTools.delta | ||
48 | w3m | ||
49 | noto-fonts-emoji | ||
50 | ripgrep-all | ||
51 | urlview | ||
52 | slop | ||
53 | gimp | ||
54 | fd | ||
55 | du-dust | ||
56 | jq | ||
57 | |||
58 | # meta | ||
59 | nixpkgs-review | ||
60 | nixpkgs-fmt | ||
61 | nix-prefetch-scripts | ||
62 | nix-bash-completions | ||
63 | |||
64 | ]; | ||
65 | |||
66 | xdg = { | ||
67 | userDirs = { | ||
68 | enable = true; | ||
69 | desktop = "\$HOME/desktop"; | ||
70 | documents = "\$HOME/docs"; | ||
71 | download = "\$HOME/dloads"; | ||
72 | music = "\$HOME/music"; | ||
73 | pictures = "\$HOME/pics"; | ||
74 | videos = "\$HOME/vids"; | ||
75 | }; | ||
76 | }; | ||
77 | |||
78 | xsession = { | ||
79 | enable = true; | ||
80 | windowManager.command = "2bwm"; | ||
81 | initExtra = '' | ||
82 | ${pkgs.hsetroot}/bin/hsetroot -solid "#000" | ||
83 | xrdb -load $HOME/.Xresources | ||
84 | setxkbmap -option 'caps:swapescape' | ||
85 | ''; | ||
86 | }; | ||
87 | |||
88 | } | ||
diff --git a/hosts/olive/configuration.nix b/hosts/olive/configuration.nix new file mode 100644 index 0000000..68b7d99 --- /dev/null +++ b/hosts/olive/configuration.nix | |||
@@ -0,0 +1,145 @@ | |||
1 | # Edit this configuration file to define what should be installed on | ||
2 | # your system. Help is available in the configuration.nix(5) man page | ||
3 | # and in the NixOS manual (accessible by running ‘nixos-help’). | ||
4 | |||
5 | { config, pkgs, lib, self, ... }: | ||
6 | |||
7 | { | ||
8 | imports = | ||
9 | [ | ||
10 | ./hardware-configuration.nix | ||
11 | ../../services/battery.nix | ||
12 | ../../services/suspend.nix | ||
13 | ]; | ||
14 | |||
15 | boot.loader.systemd-boot.enable = true; | ||
16 | boot.loader.efi.canTouchEfiVariables = true; | ||
17 | boot.kernel.sysctl."net.ipv4.ip_forward" = 1; | ||
18 | |||
19 | networking = { | ||
20 | hostName = "olive"; | ||
21 | wireless = { | ||
22 | enable = true; | ||
23 | interfaces = [ | ||
24 | "wlp2s0" | ||
25 | ]; | ||
26 | networks = { | ||
27 | Sanic = { | ||
28 | pskRaw = "03fbbe8c6b400af40c64ea475be59812ca1d13f40beaf0bf188c50a1e959c8fd"; | ||
29 | }; | ||
30 | Gopalan = { | ||
31 | pskRaw = "52f7f6548fa6f7f24965aae2bd7aa1a34d22a650cdc319d9d6a8567f91be85c8"; | ||
32 | }; | ||
33 | Srividhya = { | ||
34 | pskRaw = "f4302c17d20d0ac8791960495bb3ca4e790677d87d16a7d8c414350dd67c9713"; | ||
35 | }; | ||
36 | }; | ||
37 | extraConfig = '' | ||
38 | ctrl_interface=/run/wpa_supplicant | ||
39 | ctrl_interface_group=wheel | ||
40 | ''; | ||
41 | }; | ||
42 | useDHCP = false; | ||
43 | interfaces.wlp2s0.useDHCP = true; | ||
44 | }; | ||
45 | |||
46 | #networking.nameservers = [ "1.1.1.1" "1.0.0.1" ]; | ||
47 | |||
48 | i18n.defaultLocale = "en_US.UTF-8"; | ||
49 | time.timeZone = "Asia/Kolkata"; | ||
50 | |||
51 | nixpkgs.config = { | ||
52 | "2bwm".patches = [ | ||
53 | ../../patches/2bwm/nerd-patch.diff | ||
54 | ]; | ||
55 | |||
56 | st = { | ||
57 | conf = builtins.readFile ../../programs/st/config.h; | ||
58 | extraLibs = with pkgs; [ harfbuzz ]; | ||
59 | patches = [ | ||
60 | ../../patches/st/xres.diff | ||
61 | ../../patches/st/bright.diff | ||
62 | ../../patches/st/ligatures.diff | ||
63 | ]; | ||
64 | }; | ||
65 | }; | ||
66 | |||
67 | nixpkgs.overlays = with self.overlays; [ | ||
68 | nvim-nightly | ||
69 | ]; | ||
70 | |||
71 | environment.systemPackages = with pkgs; [ | ||
72 | _2bwm | ||
73 | manpages | ||
74 | ]; | ||
75 | |||
76 | users.motd = with config; '' | ||
77 | Host ${networking.hostName} | ||
78 | OS NixOS ${system.nixos.release} (${system.nixos.codeName}) | ||
79 | Version ${system.nixos.version} | ||
80 | Kernel ${boot.kernelPackages.kernel.version} | ||
81 | ''; | ||
82 | |||
83 | programs = { | ||
84 | light.enable = true; | ||
85 | adb.enable = true; | ||
86 | }; | ||
87 | |||
88 | |||
89 | sound.enable = true; | ||
90 | hardware.pulseaudio = { | ||
91 | enable = true; | ||
92 | package = pkgs.pulseaudioFull; | ||
93 | extraConfig = "load-module module-switch-on-connect"; | ||
94 | }; | ||
95 | |||
96 | hardware.bluetooth.enable = true; | ||
97 | hardware.bluetooth.powerOnBoot = true; | ||
98 | |||
99 | # Enable the X11 windowing system. | ||
100 | services.xserver = { | ||
101 | enable = true; | ||
102 | layout = "us"; | ||
103 | xkbOptions = "caps:swapescape"; | ||
104 | displayManager.startx.enable = true; | ||
105 | libinput.enable = true; | ||
106 | }; | ||
107 | |||
108 | services.batteryNotifier = { | ||
109 | enable = true; | ||
110 | notifyCapacity = 40; | ||
111 | suspendCapacity = 5; | ||
112 | }; | ||
113 | |||
114 | users.users.np = { | ||
115 | isNormalUser = true; | ||
116 | home = "/home/np"; | ||
117 | extraGroups = [ "wheel" "users" "tty" "audio" "video" "input" "adbusers" "docker" ]; | ||
118 | }; | ||
119 | |||
120 | documentation.man.generateCaches = true; | ||
121 | |||
122 | nix = { | ||
123 | package = pkgs.nixUnstable; | ||
124 | extraOptions = '' | ||
125 | experimental-features = nix-command flakes ca-references ca-derivations | ||
126 | warn-dirty = false | ||
127 | keep-outputs = true | ||
128 | keep-derivations = true | ||
129 | ''; | ||
130 | }; | ||
131 | |||
132 | nix.trustedUsers = | ||
133 | [ | ||
134 | "root" | ||
135 | "np" | ||
136 | ]; | ||
137 | |||
138 | # This value determines the NixOS release from which the default | ||
139 | # settings for stateful data, like file locations and database versions | ||
140 | # on your system were taken. It‘s perfectly fine and recommended to leave | ||
141 | # this value at the release version of the first install of this system. | ||
142 | # Before changing this value read the documentation for this option | ||
143 | # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). | ||
144 | system.stateVersion = "20.03"; # Did you read the comment? | ||
145 | } | ||
diff --git a/hosts/olive/hardware-configuration.nix b/hosts/olive/hardware-configuration.nix new file mode 100644 index 0000000..fc9ccb8 --- /dev/null +++ b/hosts/olive/hardware-configuration.nix | |||
@@ -0,0 +1,36 @@ | |||
1 | # Do not modify this file! It was generated by ‘nixos-generate-config’ | ||
2 | # and may be overwritten by future invocations. Please make changes | ||
3 | # to /etc/nixos/configuration.nix instead. | ||
4 | { config, lib, pkgs, modulesPath, ... }: | ||
5 | |||
6 | { | ||
7 | imports = [ | ||
8 | "${modulesPath}/installer/scan/not-detected.nix" | ||
9 | ]; | ||
10 | |||
11 | boot.initrd.availableKernelModules = [ | ||
12 | "xhci_pci" | ||
13 | "ahci" | ||
14 | "nvme" | ||
15 | "usb_storage" | ||
16 | "sd_mod" | ||
17 | ]; | ||
18 | boot.initrd.kernelModules = [ ]; | ||
19 | boot.kernelModules = [ "kvm-intel" ]; | ||
20 | boot.extraModulePackages = [ ]; | ||
21 | |||
22 | fileSystems."/" = { | ||
23 | device = "/dev/disk/by-uuid/27a7c854-e674-411f-9d79-37084922c91d"; | ||
24 | fsType = "ext4"; | ||
25 | }; | ||
26 | |||
27 | fileSystems."/boot" = { | ||
28 | device = "/dev/disk/by-uuid/882C-54D5"; | ||
29 | fsType = "vfat"; | ||
30 | }; | ||
31 | |||
32 | swapDevices = [ ]; | ||
33 | |||
34 | nix.maxJobs = lib.mkDefault 8; | ||
35 | powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; | ||
36 | } | ||
diff --git a/mail.nix b/mail.nix new file mode 100644 index 0000000..b62e51a --- /dev/null +++ b/mail.nix | |||
@@ -0,0 +1,49 @@ | |||
1 | { config | ||
2 | , lib | ||
3 | , pkgs | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | accounts.email.maildirBasePath = "mail"; | ||
9 | accounts.email.accounts."[email protected]" = { | ||
10 | address = "[email protected]"; | ||
11 | folders = { | ||
12 | drafts = "drafts"; | ||
13 | sent = "sent"; | ||
14 | trash = "trash"; | ||
15 | inbox = "inbox"; | ||
16 | }; | ||
17 | imap = { | ||
18 | host = "mail.postale.io"; | ||
19 | port = 993; | ||
20 | }; | ||
21 | maildir = { | ||
22 | path = "personal"; | ||
23 | }; | ||
24 | mbsync = { | ||
25 | enable = true; | ||
26 | create = "maildir"; | ||
27 | expunge = "maildir"; | ||
28 | }; | ||
29 | primary = true; | ||
30 | passwordCommand = "${pkgs.gnupg}/bin/gpg -q --for-your-eyes-only --no-tty -d /home/np/.password-store/email/personal.gpg"; | ||
31 | realName = "Akshay"; | ||
32 | signature = { | ||
33 | text = '' | ||
34 | -- | ||
35 | Akshay | ||
36 | <[email protected]> | ||
37 | ''; | ||
38 | }; | ||
39 | smtp = { | ||
40 | host = "mail.postale.io"; | ||
41 | port = 587; | ||
42 | tls.useStartTls = true; | ||
43 | }; | ||
44 | userName = "[email protected]"; | ||
45 | notmuch.enable = true; | ||
46 | msmtp.enable = true; | ||
47 | |||
48 | }; | ||
49 | } | ||
diff --git a/patches/2bwm/nerd-patch.diff b/patches/2bwm/nerd-patch.diff new file mode 100644 index 0000000..a47cc14 --- /dev/null +++ b/patches/2bwm/nerd-patch.diff | |||
@@ -0,0 +1,47 @@ | |||
1 | diff --git a/config.h b/config.h | ||
2 | index 0985d2e..baa77f8 100644 | ||
3 | --- a/config.h | ||
4 | +++ b/config.h | ||
5 | @@ -40,7 +40,10 @@ static const uint8_t borders[] = {3,5,5,4}; | ||
6 | #define LOOK_INTO "WM_NAME" | ||
7 | static const char *ignore_names[] = {"bar", "xclock"}; | ||
8 | ///--Menus and Programs---/// | ||
9 | -static const char *menucmd[] = { "", NULL }; | ||
10 | +// static const char *menucmd[] = { "", NULL }; | ||
11 | +static const char *terminal[] = { "st", NULL }; | ||
12 | +static const char *rofi_run[] = { "rofi", "-show", "run" }; | ||
13 | +static const char *rofi_window[] = { "rofi", "-show", "window" }; | ||
14 | ///--Custom foo---/// | ||
15 | static void halfandcentered(const Arg *arg) | ||
16 | { | ||
17 | @@ -193,7 +196,10 @@ static key keys[] = { | ||
18 | { MOD |SHIFT, XK_Right, cursor_move, {.i=TWOBWM_CURSOR_RIGHT}}, | ||
19 | { MOD |SHIFT, XK_Left, cursor_move, {.i=TWOBWM_CURSOR_LEFT}}, | ||
20 | // Start programs | ||
21 | - { MOD , XK_w, start, {.com = menucmd}}, | ||
22 | + //{ MOD , XK_w, start, {.com = menucmd}}, | ||
23 | + { MOD , XK_Return, start, {.com = terminal}}, | ||
24 | + { MOD , XK_d, start, {.com = rofi_run}}, | ||
25 | + { MOD , XK_i, start, {.com = rofi_window}}, | ||
26 | // Exit or restart 2bwm | ||
27 | { MOD |CONTROL, XK_q, twobwm_exit, {.i=0}}, | ||
28 | { MOD |CONTROL, XK_r, twobwm_restart, {.i=0}}, | ||
29 | @@ -215,7 +221,7 @@ static key keys[] = { | ||
30 | static Button buttons[] = { | ||
31 | { MOD ,XCB_BUTTON_INDEX_1, mousemotion, {.i=TWOBWM_MOVE}, false}, | ||
32 | { MOD ,XCB_BUTTON_INDEX_3, mousemotion, {.i=TWOBWM_RESIZE}, false}, | ||
33 | - { 0 ,XCB_BUTTON_INDEX_3, start, {.com = menucmd}, true}, | ||
34 | + { 0 ,XCB_BUTTON_INDEX_3, start, {.com = terminal}, true}, | ||
35 | { MOD|SHIFT, XCB_BUTTON_INDEX_1, changeworkspace, {.i=0}, false}, | ||
36 | { MOD|SHIFT, XCB_BUTTON_INDEX_3, changeworkspace, {.i=1}, false}, | ||
37 | { MOD|ALT, XCB_BUTTON_INDEX_1, changescreen, {.i=1}, false}, | ||
38 | diff --git a/definitions.h b/definitions.h | ||
39 | index a380a3a..8aa8a45 100644 | ||
40 | --- a/definitions.h | ||
41 | +++ b/definitions.h | ||
42 | @@ -1,4 +1,4 @@ | ||
43 | -#define WORKSPACES 10 | ||
44 | +#define WORKSPACES 6 | ||
45 | #define BUTTONMASK XCB_EVENT_MASK_BUTTON_PRESS|XCB_EVENT_MASK_BUTTON_RELEASE | ||
46 | #define NET_WM_FIXED 0xffffffff // Value in WM hint which means this window is fixed on all workspaces. | ||
47 | #define TWOBWM_NOWS 0xfffffffe // This means we didn't get any window hint at all. | ||
diff --git a/patches/st/bright.diff b/patches/st/bright.diff new file mode 100644 index 0000000..77379d3 --- /dev/null +++ b/patches/st/bright.diff | |||
@@ -0,0 +1,28 @@ | |||
1 | From e8f3c86d93613eef5af187dfd2dba9ae9919a2ee Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <[email protected]> | ||
3 | Date: Sun, 27 Jan 2019 13:31:28 +0800 | ||
4 | Subject: [PATCH] Show bold not as bright | ||
5 | |||
6 | --- | ||
7 | x.c | 4 ---- | ||
8 | 1 file changed, 4 deletions(-) | ||
9 | |||
10 | diff --git a/x.c b/x.c | ||
11 | index 0422421..904e1dc 100644 | ||
12 | --- a/x.c | ||
13 | +++ b/x.c | ||
14 | @@ -1296,10 +1296,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | ||
15 | bg = &dc.col[base.bg]; | ||
16 | } | ||
17 | |||
18 | - /* Change basic system colors [0-7] to bright system colors [8-15] */ | ||
19 | - if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7)) | ||
20 | - fg = &dc.col[base.fg + 8]; | ||
21 | - | ||
22 | if (IS_SET(MODE_REVERSE)) { | ||
23 | if (fg == &dc.col[defaultfg]) { | ||
24 | fg = &dc.col[defaultbg]; | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | |||
diff --git a/patches/st/ligatures.diff b/patches/st/ligatures.diff new file mode 100644 index 0000000..354443c --- /dev/null +++ b/patches/st/ligatures.diff | |||
@@ -0,0 +1,308 @@ | |||
1 | diff --git a/Makefile b/Makefile | ||
2 | index 470ac86..38240da 100644 | ||
3 | --- a/Makefile | ||
4 | +++ b/Makefile | ||
5 | @@ -4,7 +4,7 @@ | ||
6 | |||
7 | include config.mk | ||
8 | |||
9 | -SRC = st.c x.c | ||
10 | +SRC = st.c x.c hb.c | ||
11 | OBJ = $(SRC:.c=.o) | ||
12 | |||
13 | all: options st | ||
14 | @@ -22,7 +22,8 @@ config.h: | ||
15 | $(CC) $(STCFLAGS) -c $< | ||
16 | |||
17 | st.o: config.h st.h win.h | ||
18 | -x.o: arg.h config.h st.h win.h | ||
19 | +x.o: arg.h config.h st.h win.h hb.h | ||
20 | +hb.o: st.h | ||
21 | |||
22 | $(OBJ): config.h config.mk | ||
23 | |||
24 | diff --git a/config.mk b/config.mk | ||
25 | index beafc35..3df5c83 100644 | ||
26 | --- a/config.mk | ||
27 | +++ b/config.mk | ||
28 | @@ -15,10 +15,12 @@ PKG_CONFIG = pkg-config | ||
29 | # includes and libs | ||
30 | INCS = -I$(X11INC) \ | ||
31 | `$(PKG_CONFIG) --cflags fontconfig` \ | ||
32 | - `$(PKG_CONFIG) --cflags freetype2` | ||
33 | + `$(PKG_CONFIG) --cflags freetype2` \ | ||
34 | + `$(PKG_CONFIG) --cflags harfbuzz` | ||
35 | LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ | ||
36 | `$(PKG_CONFIG) --libs fontconfig` \ | ||
37 | - `$(PKG_CONFIG) --libs freetype2` | ||
38 | + `$(PKG_CONFIG) --libs freetype2` \ | ||
39 | + `$(PKG_CONFIG) --libs harfbuzz` | ||
40 | |||
41 | # flags | ||
42 | STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 | ||
43 | diff --git a/hb.c b/hb.c | ||
44 | new file mode 100644 | ||
45 | index 0000000..7df2828 | ||
46 | --- /dev/null | ||
47 | +++ b/hb.c | ||
48 | @@ -0,0 +1,136 @@ | ||
49 | +#include <stdlib.h> | ||
50 | +#include <stdio.h> | ||
51 | +#include <math.h> | ||
52 | +#include <X11/Xft/Xft.h> | ||
53 | +#include <hb.h> | ||
54 | +#include <hb-ft.h> | ||
55 | + | ||
56 | +#include "st.h" | ||
57 | + | ||
58 | +void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length); | ||
59 | +hb_font_t *hbfindfont(XftFont *match); | ||
60 | + | ||
61 | +typedef struct { | ||
62 | + XftFont *match; | ||
63 | + hb_font_t *font; | ||
64 | +} HbFontMatch; | ||
65 | + | ||
66 | +static int hbfontslen = 0; | ||
67 | +static HbFontMatch *hbfontcache = NULL; | ||
68 | + | ||
69 | +void | ||
70 | +hbunloadfonts() | ||
71 | +{ | ||
72 | + for (int i = 0; i < hbfontslen; i++) { | ||
73 | + hb_font_destroy(hbfontcache[i].font); | ||
74 | + XftUnlockFace(hbfontcache[i].match); | ||
75 | + } | ||
76 | + | ||
77 | + if (hbfontcache != NULL) { | ||
78 | + free(hbfontcache); | ||
79 | + hbfontcache = NULL; | ||
80 | + } | ||
81 | + hbfontslen = 0; | ||
82 | +} | ||
83 | + | ||
84 | +hb_font_t * | ||
85 | +hbfindfont(XftFont *match) | ||
86 | +{ | ||
87 | + for (int i = 0; i < hbfontslen; i++) { | ||
88 | + if (hbfontcache[i].match == match) | ||
89 | + return hbfontcache[i].font; | ||
90 | + } | ||
91 | + | ||
92 | + /* Font not found in cache, caching it now. */ | ||
93 | + hbfontcache = realloc(hbfontcache, sizeof(HbFontMatch) * (hbfontslen + 1)); | ||
94 | + FT_Face face = XftLockFace(match); | ||
95 | + hb_font_t *font = hb_ft_font_create(face, NULL); | ||
96 | + if (font == NULL) | ||
97 | + die("Failed to load Harfbuzz font."); | ||
98 | + | ||
99 | + hbfontcache[hbfontslen].match = match; | ||
100 | + hbfontcache[hbfontslen].font = font; | ||
101 | + hbfontslen += 1; | ||
102 | + | ||
103 | + return font; | ||
104 | +} | ||
105 | + | ||
106 | +void | ||
107 | +hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y) | ||
108 | +{ | ||
109 | + int start = 0, length = 1, gstart = 0; | ||
110 | + hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t)); | ||
111 | + | ||
112 | + for (int idx = 1, specidx = 1; idx < len; idx++) { | ||
113 | + if (glyphs[idx].mode & ATTR_WDUMMY) { | ||
114 | + length += 1; | ||
115 | + continue; | ||
116 | + } | ||
117 | + | ||
118 | + if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx]) || selected(x + idx, y) != selected(x + gstart, y)) { | ||
119 | + hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); | ||
120 | + | ||
121 | + /* Reset the sequence. */ | ||
122 | + length = 1; | ||
123 | + start = specidx; | ||
124 | + gstart = idx; | ||
125 | + } else { | ||
126 | + length += 1; | ||
127 | + } | ||
128 | + | ||
129 | + specidx++; | ||
130 | + } | ||
131 | + | ||
132 | + /* EOL. */ | ||
133 | + hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); | ||
134 | + | ||
135 | + /* Apply the transformation to glyph specs. */ | ||
136 | + for (int i = 0, specidx = 0; i < len; i++) { | ||
137 | + if (glyphs[i].mode & ATTR_WDUMMY) | ||
138 | + continue; | ||
139 | + | ||
140 | + if (codepoints[i] != specs[specidx].glyph) | ||
141 | + ((Glyph *)glyphs)[i].mode |= ATTR_LIGA; | ||
142 | + | ||
143 | + specs[specidx++].glyph = codepoints[i]; | ||
144 | + } | ||
145 | + | ||
146 | + free(codepoints); | ||
147 | +} | ||
148 | + | ||
149 | +void | ||
150 | +hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length) | ||
151 | +{ | ||
152 | + hb_font_t *font = hbfindfont(xfont); | ||
153 | + if (font == NULL) | ||
154 | + return; | ||
155 | + | ||
156 | + Rune rune; | ||
157 | + ushort mode = USHRT_MAX; | ||
158 | + hb_buffer_t *buffer = hb_buffer_create(); | ||
159 | + hb_buffer_set_direction(buffer, HB_DIRECTION_LTR); | ||
160 | + | ||
161 | + /* Fill buffer with codepoints. */ | ||
162 | + for (int i = start; i < (start+length); i++) { | ||
163 | + rune = string[i].u; | ||
164 | + mode = string[i].mode; | ||
165 | + if (mode & ATTR_WDUMMY) | ||
166 | + rune = 0x0020; | ||
167 | + hb_buffer_add_codepoints(buffer, &rune, 1, 0, 1); | ||
168 | + } | ||
169 | + | ||
170 | + /* Shape the segment. */ | ||
171 | + hb_shape(font, buffer, NULL, 0); | ||
172 | + | ||
173 | + /* Get new glyph info. */ | ||
174 | + hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL); | ||
175 | + | ||
176 | + /* Write new codepoints. */ | ||
177 | + for (int i = 0; i < length; i++) { | ||
178 | + hb_codepoint_t gid = info[i].codepoint; | ||
179 | + codepoints[start+i] = gid; | ||
180 | + } | ||
181 | + | ||
182 | + /* Cleanup. */ | ||
183 | + hb_buffer_destroy(buffer); | ||
184 | +} | ||
185 | diff --git a/hb.h b/hb.h | ||
186 | new file mode 100644 | ||
187 | index 0000000..b3e02d0 | ||
188 | --- /dev/null | ||
189 | +++ b/hb.h | ||
190 | @@ -0,0 +1,7 @@ | ||
191 | +#include <X11/Xft/Xft.h> | ||
192 | +#include <hb.h> | ||
193 | +#include <hb-ft.h> | ||
194 | + | ||
195 | +void hbunloadfonts(); | ||
196 | +void hbtransform(XftGlyphFontSpec *, const Glyph *, size_t, int, int); | ||
197 | + | ||
198 | diff --git a/st.c b/st.c | ||
199 | index 2bf133f..747f7b4 100644 | ||
200 | --- a/st.c | ||
201 | +++ b/st.c | ||
202 | @@ -2599,7 +2599,8 @@ draw(void) | ||
203 | |||
204 | drawregion(0, 0, term.col, term.row); | ||
205 | xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], | ||
206 | - term.ocx, term.ocy, term.line[term.ocy][term.ocx]); | ||
207 | + term.ocx, term.ocy, term.line[term.ocy][term.ocx], | ||
208 | + term.line[term.ocy], term.col); | ||
209 | term.ocx = cx; | ||
210 | term.ocy = term.c.y; | ||
211 | xfinishdraw(); | ||
212 | diff --git a/st.h b/st.h | ||
213 | index d978458..c9b279b 100644 | ||
214 | --- a/st.h | ||
215 | +++ b/st.h | ||
216 | @@ -11,7 +11,8 @@ | ||
217 | #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) | ||
218 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) | ||
219 | #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) | ||
220 | -#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ | ||
221 | +#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) != ((b).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) || \ | ||
222 | + (a).fg != (b).fg || \ | ||
223 | (a).bg != (b).bg) | ||
224 | #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ | ||
225 | (t1.tv_nsec-t2.tv_nsec)/1E6) | ||
226 | @@ -33,6 +34,7 @@ enum glyph_attribute { | ||
227 | ATTR_WRAP = 1 << 8, | ||
228 | ATTR_WIDE = 1 << 9, | ||
229 | ATTR_WDUMMY = 1 << 10, | ||
230 | + ATTR_LIGA = 1 << 11, | ||
231 | ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, | ||
232 | }; | ||
233 | |||
234 | diff --git a/win.h b/win.h | ||
235 | index a6ef1b9..bc0d180 100644 | ||
236 | --- a/win.h | ||
237 | +++ b/win.h | ||
238 | @@ -25,7 +25,7 @@ enum win_mode { | ||
239 | |||
240 | void xbell(void); | ||
241 | void xclipcopy(void); | ||
242 | -void xdrawcursor(int, int, Glyph, int, int, Glyph); | ||
243 | +void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int); | ||
244 | void xdrawline(Line, int, int, int); | ||
245 | void xfinishdraw(void); | ||
246 | void xloadcols(void); | ||
247 | diff --git a/x.c b/x.c | ||
248 | index e5f1737..3334a83 100644 | ||
249 | --- a/x.c | ||
250 | +++ b/x.c | ||
251 | @@ -19,6 +19,7 @@ char *argv0; | ||
252 | #include "arg.h" | ||
253 | #include "st.h" | ||
254 | #include "win.h" | ||
255 | +#include "hb.h" | ||
256 | |||
257 | /* types used in config.h */ | ||
258 | typedef struct { | ||
259 | @@ -1031,6 +1032,9 @@ xunloadfont(Font *f) | ||
260 | void | ||
261 | xunloadfonts(void) | ||
262 | { | ||
263 | + /* Clear Harfbuzz font cache. */ | ||
264 | + hbunloadfonts(); | ||
265 | + | ||
266 | /* Free the loaded fonts in the font cache. */ | ||
267 | while (frclen > 0) | ||
268 | XftFontClose(xw.dpy, frc[--frclen].font); | ||
269 | @@ -1229,7 +1233,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | ||
270 | mode = glyphs[i].mode; | ||
271 | |||
272 | /* Skip dummy wide-character spacing. */ | ||
273 | - if (mode == ATTR_WDUMMY) | ||
274 | + if (mode & ATTR_WDUMMY) | ||
275 | continue; | ||
276 | |||
277 | /* Determine font for glyph if different from previous glyph. */ | ||
278 | @@ -1336,6 +1340,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | ||
279 | numspecs++; | ||
280 | } | ||
281 | |||
282 | + /* Harfbuzz transformation for ligatures. */ | ||
283 | + hbtransform(specs, glyphs, len, x, y); | ||
284 | + | ||
285 | return numspecs; | ||
286 | } | ||
287 | |||
288 | @@ -1485,14 +1492,17 @@ xdrawglyph(Glyph g, int x, int y) | ||
289 | } | ||
290 | |||
291 | void | ||
292 | -xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) | ||
293 | +xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len) | ||
294 | { | ||
295 | Color drawcol; | ||
296 | |||
297 | /* remove the old cursor */ | ||
298 | if (selected(ox, oy)) | ||
299 | og.mode ^= ATTR_REVERSE; | ||
300 | - xdrawglyph(og, ox, oy); | ||
301 | + | ||
302 | + /* Redraw the line where cursor was previously. | ||
303 | + * It will restore the ligatures broken by the cursor. */ | ||
304 | + xdrawline(line, 0, oy, len); | ||
305 | |||
306 | if (IS_SET(MODE_HIDE)) | ||
307 | return; | ||
308 | |||
diff --git a/patches/st/xres.diff b/patches/st/xres.diff new file mode 100644 index 0000000..bac5373 --- /dev/null +++ b/patches/st/xres.diff | |||
@@ -0,0 +1,185 @@ | |||
1 | From 2752a599ee01305a435729bfacf43b1dde7cf0ef Mon Sep 17 00:00:00 2001 | ||
2 | From: Benji Encalada Mora <[email protected]> | ||
3 | Date: Thu, 4 Jun 2020 00:41:10 -0500 | ||
4 | Subject: [PATCH] fix: replace xfps and actionfps variables | ||
5 | |||
6 | --- | ||
7 | config.def.h | 36 ++++++++++++++++++++++++ | ||
8 | x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++--- | ||
9 | 2 files changed, 110 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/config.def.h b/config.def.h | ||
12 | index 6f05dce..9b99782 100644 | ||
13 | --- a/config.def.h | ||
14 | +++ b/config.def.h | ||
15 | @@ -168,6 +168,42 @@ static unsigned int defaultattr = 11; | ||
16 | */ | ||
17 | static uint forcemousemod = ShiftMask; | ||
18 | |||
19 | +/* | ||
20 | + * Xresources preferences to load at startup | ||
21 | + */ | ||
22 | +ResourcePref resources[] = { | ||
23 | + { "font", STRING, &font }, | ||
24 | + { "color0", STRING, &colorname[0] }, | ||
25 | + { "color1", STRING, &colorname[1] }, | ||
26 | + { "color2", STRING, &colorname[2] }, | ||
27 | + { "color3", STRING, &colorname[3] }, | ||
28 | + { "color4", STRING, &colorname[4] }, | ||
29 | + { "color5", STRING, &colorname[5] }, | ||
30 | + { "color6", STRING, &colorname[6] }, | ||
31 | + { "color7", STRING, &colorname[7] }, | ||
32 | + { "color8", STRING, &colorname[8] }, | ||
33 | + { "color9", STRING, &colorname[9] }, | ||
34 | + { "color10", STRING, &colorname[10] }, | ||
35 | + { "color11", STRING, &colorname[11] }, | ||
36 | + { "color12", STRING, &colorname[12] }, | ||
37 | + { "color13", STRING, &colorname[13] }, | ||
38 | + { "color14", STRING, &colorname[14] }, | ||
39 | + { "color15", STRING, &colorname[15] }, | ||
40 | + { "background", STRING, &colorname[256] }, | ||
41 | + { "foreground", STRING, &colorname[257] }, | ||
42 | + { "cursorColor", STRING, &colorname[258] }, | ||
43 | + { "termname", STRING, &termname }, | ||
44 | + { "shell", STRING, &shell }, | ||
45 | + { "minlatency", INTEGER, &minlatency }, | ||
46 | + { "maxlatency", INTEGER, &maxlatency }, | ||
47 | + { "blinktimeout", INTEGER, &blinktimeout }, | ||
48 | + { "bellvolume", INTEGER, &bellvolume }, | ||
49 | + { "tabspaces", INTEGER, &tabspaces }, | ||
50 | + { "borderpx", INTEGER, &borderpx }, | ||
51 | + { "cwscale", FLOAT, &cwscale }, | ||
52 | + { "chscale", FLOAT, &chscale }, | ||
53 | +}; | ||
54 | + | ||
55 | /* | ||
56 | * Internal mouse shortcuts. | ||
57 | * Beware that overloading Button1 will disable the selection. | ||
58 | diff --git a/x.c b/x.c | ||
59 | index 210f184..76f167f 100644 | ||
60 | --- a/x.c | ||
61 | +++ b/x.c | ||
62 | @@ -14,6 +14,7 @@ | ||
63 | #include <X11/keysym.h> | ||
64 | #include <X11/Xft/Xft.h> | ||
65 | #include <X11/XKBlib.h> | ||
66 | +#include <X11/Xresource.h> | ||
67 | |||
68 | char *argv0; | ||
69 | #include "arg.h" | ||
70 | @@ -45,6 +46,19 @@ typedef struct { | ||
71 | signed char appcursor; /* application cursor */ | ||
72 | } Key; | ||
73 | |||
74 | +/* Xresources preferences */ | ||
75 | +enum resource_type { | ||
76 | + STRING = 0, | ||
77 | + INTEGER = 1, | ||
78 | + FLOAT = 2 | ||
79 | +}; | ||
80 | + | ||
81 | +typedef struct { | ||
82 | + char *name; | ||
83 | + enum resource_type type; | ||
84 | + void *dst; | ||
85 | +} ResourcePref; | ||
86 | + | ||
87 | /* X modifiers */ | ||
88 | #define XK_ANY_MOD UINT_MAX | ||
89 | #define XK_NO_MOD 0 | ||
90 | @@ -828,8 +842,8 @@ xclear(int x1, int y1, int x2, int y2) | ||
91 | void | ||
92 | xhints(void) | ||
93 | { | ||
94 | - XClassHint class = {opt_name ? opt_name : termname, | ||
95 | - opt_class ? opt_class : termname}; | ||
96 | + XClassHint class = {opt_name ? opt_name : "st", | ||
97 | + opt_class ? opt_class : "St"}; | ||
98 | XWMHints wm = {.flags = InputHint, .input = 1}; | ||
99 | XSizeHints *sizeh; | ||
100 | |||
101 | @@ -1104,8 +1118,6 @@ xinit(int cols, int rows) | ||
102 | pid_t thispid = getpid(); | ||
103 | XColor xmousefg, xmousebg; | ||
104 | |||
105 | - if (!(xw.dpy = XOpenDisplay(NULL))) | ||
106 | - die("can't open display\n"); | ||
107 | xw.scr = XDefaultScreen(xw.dpy); | ||
108 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); | ||
109 | |||
110 | @@ -1964,6 +1976,59 @@ run(void) | ||
111 | } | ||
112 | } | ||
113 | |||
114 | +int | ||
115 | +resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) | ||
116 | +{ | ||
117 | + char **sdst = dst; | ||
118 | + int *idst = dst; | ||
119 | + float *fdst = dst; | ||
120 | + | ||
121 | + char fullname[256]; | ||
122 | + char fullclass[256]; | ||
123 | + char *type; | ||
124 | + XrmValue ret; | ||
125 | + | ||
126 | + snprintf(fullname, sizeof(fullname), "%s.%s", | ||
127 | + opt_name ? opt_name : "st", name); | ||
128 | + snprintf(fullclass, sizeof(fullclass), "%s.%s", | ||
129 | + opt_class ? opt_class : "St", name); | ||
130 | + fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; | ||
131 | + | ||
132 | + XrmGetResource(db, fullname, fullclass, &type, &ret); | ||
133 | + if (ret.addr == NULL || strncmp("String", type, 64)) | ||
134 | + return 1; | ||
135 | + | ||
136 | + switch (rtype) { | ||
137 | + case STRING: | ||
138 | + *sdst = ret.addr; | ||
139 | + break; | ||
140 | + case INTEGER: | ||
141 | + *idst = strtoul(ret.addr, NULL, 10); | ||
142 | + break; | ||
143 | + case FLOAT: | ||
144 | + *fdst = strtof(ret.addr, NULL); | ||
145 | + break; | ||
146 | + } | ||
147 | + return 0; | ||
148 | +} | ||
149 | + | ||
150 | +void | ||
151 | +config_init(void) | ||
152 | +{ | ||
153 | + char *resm; | ||
154 | + XrmDatabase db; | ||
155 | + ResourcePref *p; | ||
156 | + | ||
157 | + XrmInitialize(); | ||
158 | + resm = XResourceManagerString(xw.dpy); | ||
159 | + if (!resm) | ||
160 | + return; | ||
161 | + | ||
162 | + db = XrmGetStringDatabase(resm); | ||
163 | + for (p = resources; p < resources + LEN(resources); p++) | ||
164 | + resource_load(db, p->name, p->type, p->dst); | ||
165 | +} | ||
166 | + | ||
167 | void | ||
168 | usage(void) | ||
169 | { | ||
170 | @@ -2037,6 +2102,11 @@ run: | ||
171 | |||
172 | setlocale(LC_CTYPE, ""); | ||
173 | XSetLocaleModifiers(""); | ||
174 | + | ||
175 | + if(!(xw.dpy = XOpenDisplay(NULL))) | ||
176 | + die("Can't open display\n"); | ||
177 | + | ||
178 | + config_init(); | ||
179 | cols = MAX(cols, 1); | ||
180 | rows = MAX(rows, 1); | ||
181 | tnew(cols, rows); | ||
182 | -- | ||
183 | 2.26.2 | ||
184 | |||
185 | |||
diff --git a/programs/bash.nix b/programs/bash.nix new file mode 100644 index 0000000..cbba2de --- /dev/null +++ b/programs/bash.nix | |||
@@ -0,0 +1,88 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.bash = { | ||
8 | enable = true; | ||
9 | historyControl = [ "erasedups" ]; | ||
10 | historyFile = "\$HOME/.bash_history"; | ||
11 | historyFileSize = 2000; | ||
12 | historyIgnore = [ "ls" "exit" "kill" ]; | ||
13 | historySize = 1000; | ||
14 | shellAliases = { | ||
15 | "..." = "cd -- ../.."; | ||
16 | grep = "grep --color=auto"; | ||
17 | l = "ls -CF"; | ||
18 | la = "ls -A"; | ||
19 | ll = "ls -alF"; | ||
20 | ls = "ls -F --color=always"; | ||
21 | o = "xdg-open"; | ||
22 | rless = "less -r"; | ||
23 | tmux = "tmux -u"; | ||
24 | tree = "tree -C"; | ||
25 | vim = "nvim"; | ||
26 | tb = "nc termbin.com 9999"; | ||
27 | |||
28 | # git aliases | ||
29 | gb = "git branch -v"; | ||
30 | gc = "git commit --verbose"; | ||
31 | gd = "git diff --minimal"; | ||
32 | ggp = "git push"; | ||
33 | gl = "git log -p --abbrev-commit --pretty=medium"; | ||
34 | glo = "git log --pretty=oneline --abbrev-commit"; | ||
35 | gst = "git status --short"; | ||
36 | }; | ||
37 | shellOptions = [ | ||
38 | "histappend" | ||
39 | "autocd" | ||
40 | "globstar" | ||
41 | "checkwinsize" | ||
42 | "cdspell" | ||
43 | "dirspell" | ||
44 | "expand_aliases" | ||
45 | "dotglob" | ||
46 | "gnu_errfmt" | ||
47 | "histreedit" | ||
48 | "nocasematch" | ||
49 | ]; | ||
50 | sessionVariables = { | ||
51 | PROMPT_CHAR = "λ"; | ||
52 | PROMPT_CHAR_COLOR = "cyan"; | ||
53 | PROMPT_CHAR_ROOT = "#"; | ||
54 | PROMPT_CHAR_ROOT_COLOR = "magenta"; | ||
55 | SHORTEN_CWD = 1; | ||
56 | CWD_COLOR = "white"; | ||
57 | EXPAND_TILDE = 0; | ||
58 | GIT_CLEAN = "·"; | ||
59 | GIT_CLEAN_COLOR = "green"; | ||
60 | GIT_WT_MODIFIED = "×"; | ||
61 | GIT_WT_MODIFIED_COLOR = "red"; | ||
62 | GIT_INDEX_MODIFIED = "±"; | ||
63 | GIT_INDEX_MODIFIED_COLOR = "yellow"; | ||
64 | BRANCH_COLOR = "bright black"; | ||
65 | COMMIT_COLOR = "green"; | ||
66 | PF_INFO = "ascii title os kernel uptime pkgs shell "; | ||
67 | PF_SEP = " "; | ||
68 | PF_COL1 = 7; | ||
69 | PF_COL2 = 7; | ||
70 | PF_COL3 = 6; | ||
71 | PF_ALIGN = "9"; | ||
72 | PF_ASCII = "nixos"; | ||
73 | _JAVA_AWT_WM_NONREPARENTING = 1; | ||
74 | TERM = "xterm-256color-italic"; | ||
75 | EDITOR = "nvim"; | ||
76 | MANPAGER = "nvim +Man!"; | ||
77 | GPG_TTY = "\$(tty)"; | ||
78 | }; | ||
79 | initExtra = '' | ||
80 | [ -f $HOME/.github ] && . $HOME/.github | ||
81 | [ -f ~/.bash_aliases ] && . ~/.bash_aliases | ||
82 | [ -f ~/.fzf.bash ] && source ~/.fzf.bash | ||
83 | eval "$(direnv hook bash)" | ||
84 | export PS1='\n$(pista)' | ||
85 | export PATH=$PATH:"$HOME/scripts" | ||
86 | ''; | ||
87 | }; | ||
88 | } | ||
diff --git a/programs/chromium.nix b/programs/chromium.nix new file mode 100644 index 0000000..975e721 --- /dev/null +++ b/programs/chromium.nix | |||
@@ -0,0 +1,18 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.chromium = { | ||
8 | enable = true; | ||
9 | extensions = [ | ||
10 | "gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere | ||
11 | "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin | ||
12 | "aapbdbdomjkkjkaonfhkkikfgjllcleb" # translate | ||
13 | "aghfnjkcakhmadgdomlmlhhaocbkloab" # just black | ||
14 | "pobhoodpcipjmedfenaigbeloiidbflp" # minimal twitter | ||
15 | "ennpfpdlaclocpomkiablnmbppdnlhoh" # rust search extension | ||
16 | ]; | ||
17 | }; | ||
18 | } | ||
diff --git a/programs/default.nix b/programs/default.nix new file mode 100644 index 0000000..ba67638 --- /dev/null +++ b/programs/default.nix | |||
@@ -0,0 +1,51 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | |||
9 | imports = [ | ||
10 | ./bash.nix | ||
11 | ./chromium.nix | ||
12 | ./feh.nix | ||
13 | ./git.nix | ||
14 | ./htop.nix | ||
15 | ./neovim.nix | ||
16 | ./readline.nix | ||
17 | ./tmux.nix | ||
18 | ./zathura.nix | ||
19 | ]; | ||
20 | |||
21 | programs = { | ||
22 | msmtp.enable = true; | ||
23 | home-manager.enable = true; | ||
24 | mbsync.enable = true; | ||
25 | direnv = { | ||
26 | enable = true; | ||
27 | enableBashIntegration = true; | ||
28 | nix-direnv = { | ||
29 | enable = true; | ||
30 | useFlakes = true; | ||
31 | }; | ||
32 | }; | ||
33 | autojump = { | ||
34 | enable = true; | ||
35 | enableBashIntegration = true; | ||
36 | }; | ||
37 | password-store = { | ||
38 | enable = true; | ||
39 | settings = { | ||
40 | PASSWORD_STORE_DIR = ''$HOME/.password-store''; | ||
41 | PASSWORD_STORE_KEY = "21532E14CF0840E438C36DED7164B95E9556624A"; | ||
42 | PASSWORD_STORE_CLIP_TIME = "60"; | ||
43 | }; | ||
44 | }; | ||
45 | nix-index = { | ||
46 | enable = true; | ||
47 | enableBashIntegration = true; | ||
48 | }; | ||
49 | gpg.enable = true; | ||
50 | }; | ||
51 | } | ||
diff --git a/programs/feh.nix b/programs/feh.nix new file mode 100644 index 0000000..2e15fe4 --- /dev/null +++ b/programs/feh.nix | |||
@@ -0,0 +1,14 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.feh = { | ||
8 | enable = true; | ||
9 | buttons = { | ||
10 | zoom_in = "C-5"; | ||
11 | zoom_out = "C-4"; | ||
12 | }; | ||
13 | }; | ||
14 | } | ||
diff --git a/programs/fzf.nix b/programs/fzf.nix new file mode 100644 index 0000000..b02a07c --- /dev/null +++ b/programs/fzf.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | { | ||
2 | enable = true; | ||
3 | enableBashIntegration = true; | ||
4 | defaultOptions = ["--height 40%" "--layout=reverse" "--color=bw"]; | ||
5 | defaultCommand = "rg -L --files"; | ||
6 | changeDirWidgetCommand = "find . -type d"; | ||
7 | } | ||
diff --git a/programs/git.nix b/programs/git.nix new file mode 100644 index 0000000..1a2bc72 --- /dev/null +++ b/programs/git.nix | |||
@@ -0,0 +1,48 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | programs.git = { | ||
10 | enable = true; | ||
11 | ignores = [ ".envrc" ]; | ||
12 | userEmail = "[email protected]"; | ||
13 | userName = "Akshay"; | ||
14 | delta = { | ||
15 | enable = true; | ||
16 | options = { | ||
17 | features = "decorations labels"; | ||
18 | syntax-theme = "none"; | ||
19 | zero-style = "8"; | ||
20 | navigate = "true"; | ||
21 | keep-plus-minus-markers = "true"; | ||
22 | decorations = { | ||
23 | file-decoration-style = "none"; | ||
24 | whitespace-error-style = "22 reverse"; | ||
25 | minus-style = "${base08}"; | ||
26 | minus-emph-style = "${base08} bold"; | ||
27 | plus-style = "${base0B}"; | ||
28 | plus-emph-style = "${base0B} bold"; | ||
29 | file-style = "7 italic"; | ||
30 | hunk-header-style = "7"; | ||
31 | hunk-header-decoration-style = "8 ul"; | ||
32 | }; | ||
33 | labels = { | ||
34 | file-modified-label = " MODIFIED "; | ||
35 | file-removed-label = " REMOVED "; | ||
36 | file-added-label = " ADDED "; | ||
37 | file-renamed-label = " RENAMED "; | ||
38 | }; | ||
39 | }; | ||
40 | }; | ||
41 | extraConfig = { | ||
42 | commit.verbose = true; | ||
43 | core = { | ||
44 | hooksPath = "/home/np/.hooks"; | ||
45 | }; | ||
46 | }; | ||
47 | }; | ||
48 | } | ||
diff --git a/programs/htop.nix b/programs/htop.nix new file mode 100644 index 0000000..a48b70c --- /dev/null +++ b/programs/htop.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.htop = { | ||
8 | enable = true; | ||
9 | settings.color_scheme = 1; # monochrome | ||
10 | }; | ||
11 | } | ||
diff --git a/programs/init.vim b/programs/init.vim new file mode 100644 index 0000000..38e5eef --- /dev/null +++ b/programs/init.vim | |||
@@ -0,0 +1,191 @@ | |||
1 | let &t_ZM = "\e[3m" | ||
2 | |||
3 | call plug#begin('~/.local/share/nvim/plugged') | ||
4 | |||
5 | " syntax and friends | ||
6 | Plug 'neovimhaskell/haskell-vim', {'for': ['haskell', 'cabal']} | ||
7 | Plug 'elmcast/elm-vim' | ||
8 | |||
9 | " my stuff | ||
10 | Plug 'git@ferrn:vim/vim-colors-plain' | ||
11 | Plug 'git@ferrn:vim/better-text-objs' | ||
12 | |||
13 | call plug#end() | ||
14 | |||
15 | |||
16 | " augroups | ||
17 | |||
18 | augroup plaintext | ||
19 | autocmd! | ||
20 | autocmd FileType text,markdown setlocal ts=2 sts=2 sw=2 expandtab textwidth=60 | ||
21 | augroup END | ||
22 | |||
23 | augroup webdev | ||
24 | autocmd! | ||
25 | autocmd FileType less,css,html,js?,ts? setlocal ts=2 sts=2 sw=2 expandtab | ||
26 | autocmd FileType less,css,html nnoremap <Leader>s viB:sort<cr> | ||
27 | augroup END | ||
28 | |||
29 | augroup lisp_stuff | ||
30 | autocmd! | ||
31 | autocmd BufReadPost *.lisp set filetype=scheme | ||
32 | augroup END | ||
33 | |||
34 | augroup yankhl | ||
35 | autocmd! | ||
36 | autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank() | ||
37 | augroup END | ||
38 | |||
39 | augroup restorecursor | ||
40 | autocmd BufReadPost * | ||
41 | \ if line("'\"") > 1 && line("'\"") <= line("$") | | ||
42 | \ execute "normal! g`\"" | | ||
43 | \ endif | ||
44 | augroup END | ||
45 | |||
46 | augroup fzfstatus | ||
47 | if has('nvim') && !exists('g:fzf_layout') | ||
48 | autocmd! FileType fzf | ||
49 | autocmd FileType fzf set laststatus=0 noshowmode noruler | ||
50 | \| autocmd BufLeave <buffer> set laststatus=2 showmode ruler | ||
51 | endif | ||
52 | augroup END | ||
53 | |||
54 | augroup completions | ||
55 | " Use completion-nvim in every buffer | ||
56 | autocmd! | ||
57 | autocmd BufEnter * lua require'completion'.on_attach() | ||
58 | augroup END | ||
59 | |||
60 | " general settings | ||
61 | set nobackup | ||
62 | set nowritebackup | ||
63 | set noswapfile " get rid of swapfiles everywhere | ||
64 | set dir=/tmp | ||
65 | |||
66 | syntax on | ||
67 | |||
68 | set omnifunc=syntaxcomplete#Complete | ||
69 | set completefunc=LanguageClient#complete | ||
70 | set list | ||
71 | filetype off | ||
72 | filetype plugin indent on | ||
73 | set laststatus=2 | ||
74 | set nowrap | ||
75 | set noshowmode | ||
76 | set listchars=tab:┊\ ,nbsp:␣,trail:·,extends:>,precedes:< | ||
77 | set fillchars=vert:\│,stl:\ ,stlnc:\ | ||
78 | set ignorecase | ||
79 | set smartcase | ||
80 | set sidescroll=40 | ||
81 | set incsearch | ||
82 | set hlsearch | ||
83 | set undofile | ||
84 | set undodir=~/tmp | ||
85 | set path+=** | ||
86 | set backspace=indent,eol,start | ||
87 | set hidden | ||
88 | set wildmenu | ||
89 | set complete=.,w,b,i,u,t, | ||
90 | set background=dark | ||
91 | set mouse=a | ||
92 | set conceallevel=0 | ||
93 | set nonumber | ||
94 | set grepprg=rg\ --vimgrep\ --no-heading | ||
95 | set grepformat=%f:%l:%c:%m,%f:%l:%m | ||
96 | set cmdheight=2 | ||
97 | set shortmess+=c | ||
98 | set updatetime=300 | ||
99 | set signcolumn=yes | ||
100 | set inccommand=split | ||
101 | set showmatch | ||
102 | set diffopt+=vertical | ||
103 | set completeopt=menuone,noinsert,noselect | ||
104 | set exrc | ||
105 | |||
106 | let g:netrw_browsex_viewer= "xdg-open" | ||
107 | |||
108 | colorscheme plain | ||
109 | |||
110 | set shiftwidth=4 " indent = 4 spaces | ||
111 | set expandtab | ||
112 | set tabstop=4 " tab = 4 spaces | ||
113 | set softtabstop=4 " backspace through spaces | ||
114 | |||
115 | " Functions | ||
116 | function! GetTabber() " a lil function that integrates well with Tabular.vim | ||
117 | let c = nr2char(getchar()) | ||
118 | :execute 'Tabularize /' . c | ||
119 | endfunction | ||
120 | |||
121 | " Ugh | ||
122 | command! WQ wq | ||
123 | command! Wq wq | ||
124 | command! Wqa wqa | ||
125 | command! WQa wqa | ||
126 | command! W w | ||
127 | command! Q q | ||
128 | |||
129 | " abbreviations | ||
130 | abclear | ||
131 | iab #i #include | ||
132 | iab #d #define | ||
133 | cab dst put =strftime('%d %a, %b %Y')<cr> | ||
134 | cab vg vimgrep | ||
135 | cab vga vimgrepadd | ||
136 | cab bfd bufdo | ||
137 | |||
138 | " man pages | ||
139 | let g:ft_man_open_mode = 'tab' | ||
140 | |||
141 | let g:gitgutter_override_sign_column_highlight = 0 | ||
142 | let g:gitgutter_sign_added = '+' | ||
143 | let g:gitgutter_sign_modified = '~' | ||
144 | let g:gitgutter_sign_removed = '-' | ||
145 | let g:gitgutter_sign_removed_first_line = '-' | ||
146 | let g:gitgutter_sign_modified_removed = '~' | ||
147 | |||
148 | let g:fzf_colors = | ||
149 | \ { 'fg': ['fg', 'Noise'], | ||
150 | \ 'bg': ['bg', 'Noise'], | ||
151 | \ 'hl': ['fg', 'Statement'], | ||
152 | \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | ||
153 | \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | ||
154 | \ 'hl+': ['fg', 'Statement'], | ||
155 | \ 'info': ['fg', 'PreProc'], | ||
156 | \ 'border': ['fg', 'Ignore'], | ||
157 | \ 'prompt': ['fg', 'Conditional'], | ||
158 | \ 'pointer': ['fg', 'Exception'], | ||
159 | \ 'marker': ['fg', 'Keyword'], | ||
160 | \ 'spinner': ['fg', 'Label'], | ||
161 | \ 'header': ['fg', 'Comment'] } | ||
162 | let g:fzf_layout = { 'down': '40%' } | ||
163 | let g:fzf_preview_window = [] | ||
164 | |||
165 | highlight GitGutterAdd ctermfg=8 | ||
166 | highlight GitGutterChange ctermfg=8 | ||
167 | highlight GitGutterDelete ctermfg=8 | ||
168 | |||
169 | let g:rustfmt_autosave = 1 | ||
170 | |||
171 | let g:latex_view_general_viewer = "zathura" | ||
172 | let g:vimtex_view_method = "zathura" | ||
173 | let g:tex_flavor = 'latex' | ||
174 | |||
175 | let g:elm_setup_keybindings = 0 | ||
176 | |||
177 | let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy', 'all'] | ||
178 | let g:completion_trigger_on_delete = 1 | ||
179 | |||
180 | sign define LspDiagnosticsSignError text=× texthl=LspDiagnosticsSignError linehl= numhl= | ||
181 | sign define LspDiagnosticsSignWarning text=\! texthl=LspDiagnosticsSignWarning linehl= numhl= | ||
182 | sign define LspDiagnosticsSignInformation text=i texthl=LspDiagnosticsSignInformation linehl= numhl= | ||
183 | sign define LspDiagnosticsSignHint text=\~ texthl=LspDiagnosticsSignHint linehl= numhl= | ||
184 | |||
185 | let g:user_emmet_leader_key='<C-X>' | ||
186 | |||
187 | lua << EOF | ||
188 | require 'lsp' | ||
189 | require 'treesitter' | ||
190 | EOF | ||
191 | |||
diff --git a/programs/neovim.nix b/programs/neovim.nix new file mode 100644 index 0000000..18baeac --- /dev/null +++ b/programs/neovim.nix | |||
@@ -0,0 +1,45 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.neovim = { | ||
8 | enable = true; | ||
9 | extraConfig = builtins.readFile ./init.vim; | ||
10 | withNodeJs = false; | ||
11 | vimAlias = true; | ||
12 | withPython3 = true; | ||
13 | extraPackages = with pkgs; [ | ||
14 | gcc | ||
15 | python37Packages.yapf | ||
16 | hlint | ||
17 | ocamlformat | ||
18 | ocamlPackages.ocaml-lsp | ||
19 | ]; | ||
20 | plugins = with pkgs.vimPlugins; [ | ||
21 | # neovim only | ||
22 | nvim-lspconfig | ||
23 | (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars)) | ||
24 | completion-nvim | ||
25 | |||
26 | # tpope | ||
27 | vim-surround | ||
28 | vim-unimpaired | ||
29 | vim-repeat | ||
30 | # vim-fugitive | ||
31 | |||
32 | # syntax | ||
33 | rust-vim | ||
34 | vim-nix | ||
35 | vimtex | ||
36 | |||
37 | # handy | ||
38 | # vim-gitgutter | ||
39 | tabular | ||
40 | emmet-vim | ||
41 | vimwiki | ||
42 | fzf-vim | ||
43 | ]; | ||
44 | }; | ||
45 | } | ||
diff --git a/programs/readline.nix b/programs/readline.nix new file mode 100644 index 0000000..be43ace --- /dev/null +++ b/programs/readline.nix | |||
@@ -0,0 +1,22 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.readline = { | ||
8 | enable = true; | ||
9 | bindings = { | ||
10 | "\\C-o" = ''"$HOME/scripts/tmux-fzf.sh\n"''; | ||
11 | "\\t" = "menu-complete"; | ||
12 | "\\e[Z" = "menu-complete-backward"; | ||
13 | }; | ||
14 | variables = { | ||
15 | "completion-ignore-case" = "on"; | ||
16 | "show-all-if-ambiguous" = "on"; | ||
17 | "colored-stats" = "on"; | ||
18 | "completion-display-width" = 4; | ||
19 | "enable-bracketed-paste" = "on"; | ||
20 | }; | ||
21 | }; | ||
22 | } | ||
diff --git a/programs/st/config.h b/programs/st/config.h new file mode 100644 index 0000000..696b99f --- /dev/null +++ b/programs/st/config.h | |||
@@ -0,0 +1,507 @@ | |||
1 | |||
2 | /* See LICENSE file for copyright and license details. */ | ||
3 | |||
4 | /* | ||
5 | * appearance | ||
6 | * | ||
7 | * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html | ||
8 | */ | ||
9 | static char *font = "Nerd Input:pixelsize=12:antialias=true:autohint=true"; | ||
10 | static int borderpx = 30; | ||
11 | |||
12 | /* | ||
13 | * What program is execed by st depends of these precedence rules: | ||
14 | * 1: program passed with -e | ||
15 | * 2: scroll and/or utmp | ||
16 | * 3: SHELL environment variable | ||
17 | * 4: value of shell in /etc/passwd | ||
18 | * 5: value of shell in config.h | ||
19 | */ | ||
20 | static char *shell = "/run/current-system/sw/bin/bash"; | ||
21 | char *utmp = NULL; | ||
22 | /* scroll program: to enable use a string like "scroll" */ | ||
23 | char *scroll = NULL; | ||
24 | char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; | ||
25 | |||
26 | /* identification sequence returned in DA and DECID */ | ||
27 | char *vtiden = "\033[?6c"; | ||
28 | |||
29 | /* Kerning / character bounding-box multipliers */ | ||
30 | static float cwscale = 0.9; | ||
31 | static float chscale = 1.0; | ||
32 | |||
33 | /* | ||
34 | * word delimiter string | ||
35 | * | ||
36 | * More advanced example: L" `'\"()[]{}" | ||
37 | */ | ||
38 | wchar_t *worddelimiters = L" "; | ||
39 | |||
40 | /* selection timeouts (in milliseconds) */ | ||
41 | static unsigned int doubleclicktimeout = 300; | ||
42 | static unsigned int tripleclicktimeout = 600; | ||
43 | |||
44 | /* alt screens */ | ||
45 | int allowaltscreen = 1; | ||
46 | |||
47 | /* allow certain non-interactive (insecure) window operations such as: | ||
48 | setting the clipboard text */ | ||
49 | int allowwindowops = 0; | ||
50 | |||
51 | /* | ||
52 | * draw latency range in ms - from new content/keypress/etc until drawing. | ||
53 | * within this range, st draws when content stops arriving (idle). mostly it's | ||
54 | * near minlatency, but it waits longer for slow updates to avoid partial draw. | ||
55 | * low minlatency will tear/flicker more, as it can "detect" idle too early. | ||
56 | */ | ||
57 | static double minlatency = 8; | ||
58 | static double maxlatency = 33; | ||
59 | |||
60 | /* | ||
61 | * blinking timeout (set to 0 to disable blinking) for the terminal blinking | ||
62 | * attribute. | ||
63 | */ | ||
64 | static unsigned int blinktimeout = 800; | ||
65 | |||
66 | /* | ||
67 | * thickness of underline and bar cursors | ||
68 | */ | ||
69 | static unsigned int cursorthickness = 2; | ||
70 | |||
71 | /* | ||
72 | * bell volume. It must be a value between -100 and 100. Use 0 for disabling | ||
73 | * it | ||
74 | */ | ||
75 | static int bellvolume = 0; | ||
76 | |||
77 | /* default TERM value */ | ||
78 | char *termname = "xterm-256color-italic"; | ||
79 | |||
80 | /* | ||
81 | * spaces per tab | ||
82 | * | ||
83 | * When you are changing this value, don't forget to adapt the »it« value in | ||
84 | * the st.info and appropriately install the st.info in the environment where | ||
85 | * you use this st version. | ||
86 | * | ||
87 | * it#$tabspaces, | ||
88 | * | ||
89 | * Secondly make sure your kernel is not expanding tabs. When running `stty | ||
90 | * -a` »tab0« should appear. You can tell the terminal to not expand tabs by | ||
91 | * running following command: | ||
92 | * | ||
93 | * stty tabs | ||
94 | */ | ||
95 | unsigned int tabspaces = 4; | ||
96 | |||
97 | /* Terminal colors (16 first used in escape sequence) */ | ||
98 | static const char *colorname[] = { | ||
99 | /* 8 normal colors */ | ||
100 | "black", | ||
101 | "red3", | ||
102 | "green3", | ||
103 | "yellow3", | ||
104 | "blue2", | ||
105 | "magenta3", | ||
106 | "cyan3", | ||
107 | "gray90", | ||
108 | |||
109 | /* 8 bright colors */ | ||
110 | "gray50", | ||
111 | "red", | ||
112 | "green", | ||
113 | "yellow", | ||
114 | "#5c5cff", | ||
115 | "magenta", | ||
116 | "cyan", | ||
117 | "white", | ||
118 | |||
119 | [255] = 0, | ||
120 | |||
121 | /* more colors can be added after 255 to use with DefaultXX */ | ||
122 | "#cccccc", | ||
123 | "#555555", | ||
124 | }; | ||
125 | |||
126 | |||
127 | /* | ||
128 | * Default colors (colorname index) | ||
129 | * foreground, background, cursor, reverse cursor | ||
130 | */ | ||
131 | unsigned int defaultfg = 7; | ||
132 | unsigned int defaultbg = 0; | ||
133 | static unsigned int defaultcs = 256; | ||
134 | static unsigned int defaultrcs = 257; | ||
135 | |||
136 | /* | ||
137 | * Default shape of cursor | ||
138 | * 2: Block ("█") | ||
139 | * 4: Underline ("_") | ||
140 | * 6: Bar ("|") | ||
141 | * 7: Snowman ("☃") | ||
142 | */ | ||
143 | static unsigned int cursorshape = 2; | ||
144 | |||
145 | /* | ||
146 | * Default columns and rows numbers | ||
147 | */ | ||
148 | |||
149 | static unsigned int cols = 80; | ||
150 | static unsigned int rows = 24; | ||
151 | |||
152 | /* | ||
153 | * Default colour and shape of the mouse cursor | ||
154 | */ | ||
155 | static unsigned int mouseshape = XC_xterm; | ||
156 | static unsigned int mousefg = 7; | ||
157 | static unsigned int mousebg = 0; | ||
158 | |||
159 | /* | ||
160 | * Color used to display font attributes when fontconfig selected a font which | ||
161 | * doesn't match the ones requested. | ||
162 | */ | ||
163 | static unsigned int defaultattr = 11; | ||
164 | |||
165 | /* | ||
166 | * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). | ||
167 | * Note that if you want to use ShiftMask with selmasks, set this to an other | ||
168 | * modifier, set to 0 to not use it. | ||
169 | */ | ||
170 | static uint forcemousemod = ShiftMask; | ||
171 | |||
172 | ResourcePref resources[] = { | ||
173 | { "font", STRING, &font }, | ||
174 | { "color0", STRING, &colorname[0] }, | ||
175 | { "color1", STRING, &colorname[1] }, | ||
176 | { "color2", STRING, &colorname[2] }, | ||
177 | { "color3", STRING, &colorname[3] }, | ||
178 | { "color4", STRING, &colorname[4] }, | ||
179 | { "color5", STRING, &colorname[5] }, | ||
180 | { "color6", STRING, &colorname[6] }, | ||
181 | { "color7", STRING, &colorname[7] }, | ||
182 | { "color8", STRING, &colorname[8] }, | ||
183 | { "color9", STRING, &colorname[9] }, | ||
184 | { "color10", STRING, &colorname[10] }, | ||
185 | { "color11", STRING, &colorname[11] }, | ||
186 | { "color12", STRING, &colorname[12] }, | ||
187 | { "color13", STRING, &colorname[13] }, | ||
188 | { "color14", STRING, &colorname[14] }, | ||
189 | { "color15", STRING, &colorname[15] }, | ||
190 | { "background", STRING, &colorname[0] }, | ||
191 | { "foreground", STRING, &colorname[7] }, | ||
192 | { "cursorColor", STRING, &colorname[7] }, | ||
193 | { "termname", STRING, &termname }, | ||
194 | { "shell", STRING, &shell }, | ||
195 | { "minlatency", INTEGER, &minlatency }, | ||
196 | { "maxlatency", INTEGER, &maxlatency }, | ||
197 | { "blinktimeout", INTEGER, &blinktimeout }, | ||
198 | { "bellvolume", INTEGER, &bellvolume }, | ||
199 | { "tabspaces", INTEGER, &tabspaces }, | ||
200 | { "borderpx", INTEGER, &borderpx }, | ||
201 | { "cwscale", FLOAT, &cwscale }, | ||
202 | { "chscale", FLOAT, &chscale }, | ||
203 | }; | ||
204 | |||
205 | /* | ||
206 | * Internal mouse shortcuts. | ||
207 | * Beware that overloading Button1 will disable the selection. | ||
208 | */ | ||
209 | static MouseShortcut mshortcuts[] = { | ||
210 | /* mask button function argument release */ | ||
211 | { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, | ||
212 | { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, | ||
213 | { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, | ||
214 | { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, | ||
215 | { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, | ||
216 | }; | ||
217 | |||
218 | /* Internal keyboard shortcuts. */ | ||
219 | #define MODKEY Mod1Mask | ||
220 | #define TERMMOD (ControlMask|ShiftMask) | ||
221 | |||
222 | static Shortcut shortcuts[] = { | ||
223 | /* mask keysym function argument */ | ||
224 | { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, | ||
225 | { ControlMask, XK_Print, toggleprinter, {.i = 0} }, | ||
226 | { ShiftMask, XK_Print, printscreen, {.i = 0} }, | ||
227 | { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, | ||
228 | { TERMMOD, XK_Prior, zoom, {.f = +1} }, | ||
229 | { TERMMOD, XK_Next, zoom, {.f = -1} }, | ||
230 | { TERMMOD, XK_Home, zoomreset, {.f = 0} }, | ||
231 | { TERMMOD, XK_C, clipcopy, {.i = 0} }, | ||
232 | { TERMMOD, XK_V, clippaste, {.i = 0} }, | ||
233 | { TERMMOD, XK_Y, selpaste, {.i = 0} }, | ||
234 | { ShiftMask, XK_Insert, selpaste, {.i = 0} }, | ||
235 | { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, | ||
236 | }; | ||
237 | |||
238 | /* | ||
239 | * Special keys (change & recompile st.info accordingly) | ||
240 | * | ||
241 | * Mask value: | ||
242 | * * Use XK_ANY_MOD to match the key no matter modifiers state | ||
243 | * * Use XK_NO_MOD to match the key alone (no modifiers) | ||
244 | * appkey value: | ||
245 | * * 0: no value | ||
246 | * * > 0: keypad application mode enabled | ||
247 | * * = 2: term.numlock = 1 | ||
248 | * * < 0: keypad application mode disabled | ||
249 | * appcursor value: | ||
250 | * * 0: no value | ||
251 | * * > 0: cursor application mode enabled | ||
252 | * * < 0: cursor application mode disabled | ||
253 | * | ||
254 | * Be careful with the order of the definitions because st searches in | ||
255 | * this table sequentially, so any XK_ANY_MOD must be in the last | ||
256 | * position for a key. | ||
257 | */ | ||
258 | |||
259 | /* | ||
260 | * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) | ||
261 | * to be mapped below, add them to this array. | ||
262 | */ | ||
263 | static KeySym mappedkeys[] = { -1 }; | ||
264 | |||
265 | /* | ||
266 | * State bits to ignore when matching key or button events. By default, | ||
267 | * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. | ||
268 | */ | ||
269 | static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; | ||
270 | |||
271 | /* | ||
272 | * This is the huge key array which defines all compatibility to the Linux | ||
273 | * world. Please decide about changes wisely. | ||
274 | */ | ||
275 | static Key key[] = { | ||
276 | /* keysym mask string appkey appcursor */ | ||
277 | { XK_KP_Home, ShiftMask, "\033[2J", 0, -1}, | ||
278 | { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1}, | ||
279 | { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1}, | ||
280 | { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1}, | ||
281 | { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0}, | ||
282 | { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1}, | ||
283 | { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1}, | ||
284 | { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0}, | ||
285 | { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1}, | ||
286 | { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1}, | ||
287 | { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0}, | ||
288 | { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1}, | ||
289 | { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1}, | ||
290 | { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0}, | ||
291 | { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1}, | ||
292 | { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1}, | ||
293 | { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0}, | ||
294 | { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, | ||
295 | { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0}, | ||
296 | { XK_KP_End, ControlMask, "\033[J", -1, 0}, | ||
297 | { XK_KP_End, ControlMask, "\033[1;5F", +1, 0}, | ||
298 | { XK_KP_End, ShiftMask, "\033[K", -1, 0}, | ||
299 | { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0}, | ||
300 | { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0}, | ||
301 | { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0}, | ||
302 | { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0}, | ||
303 | { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0}, | ||
304 | { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0}, | ||
305 | { XK_KP_Insert, ControlMask, "\033[L", -1, 0}, | ||
306 | { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0}, | ||
307 | { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, | ||
308 | { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, | ||
309 | { XK_KP_Delete, ControlMask, "\033[M", -1, 0}, | ||
310 | { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0}, | ||
311 | { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0}, | ||
312 | { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0}, | ||
313 | { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0}, | ||
314 | { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, | ||
315 | { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0}, | ||
316 | { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0}, | ||
317 | { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0}, | ||
318 | { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0}, | ||
319 | { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0}, | ||
320 | { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0}, | ||
321 | { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0}, | ||
322 | { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0}, | ||
323 | { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0}, | ||
324 | { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0}, | ||
325 | { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0}, | ||
326 | { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0}, | ||
327 | { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0}, | ||
328 | { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0}, | ||
329 | { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0}, | ||
330 | { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0}, | ||
331 | { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0}, | ||
332 | { XK_Up, ShiftMask, "\033[1;2A", 0, 0}, | ||
333 | { XK_Up, Mod1Mask, "\033[1;3A", 0, 0}, | ||
334 | { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0}, | ||
335 | { XK_Up, ControlMask, "\033[1;5A", 0, 0}, | ||
336 | { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0}, | ||
337 | { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0}, | ||
338 | { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0}, | ||
339 | { XK_Up, XK_ANY_MOD, "\033[A", 0, -1}, | ||
340 | { XK_Up, XK_ANY_MOD, "\033OA", 0, +1}, | ||
341 | { XK_Down, ShiftMask, "\033[1;2B", 0, 0}, | ||
342 | { XK_Down, Mod1Mask, "\033[1;3B", 0, 0}, | ||
343 | { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0}, | ||
344 | { XK_Down, ControlMask, "\033[1;5B", 0, 0}, | ||
345 | { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0}, | ||
346 | { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0}, | ||
347 | { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0}, | ||
348 | { XK_Down, XK_ANY_MOD, "\033[B", 0, -1}, | ||
349 | { XK_Down, XK_ANY_MOD, "\033OB", 0, +1}, | ||
350 | { XK_Left, ShiftMask, "\033[1;2D", 0, 0}, | ||
351 | { XK_Left, Mod1Mask, "\033[1;3D", 0, 0}, | ||
352 | { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0}, | ||
353 | { XK_Left, ControlMask, "\033[1;5D", 0, 0}, | ||
354 | { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0}, | ||
355 | { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0}, | ||
356 | { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0}, | ||
357 | { XK_Left, XK_ANY_MOD, "\033[D", 0, -1}, | ||
358 | { XK_Left, XK_ANY_MOD, "\033OD", 0, +1}, | ||
359 | { XK_Right, ShiftMask, "\033[1;2C", 0, 0}, | ||
360 | { XK_Right, Mod1Mask, "\033[1;3C", 0, 0}, | ||
361 | { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0}, | ||
362 | { XK_Right, ControlMask, "\033[1;5C", 0, 0}, | ||
363 | { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0}, | ||
364 | { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0}, | ||
365 | { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0}, | ||
366 | { XK_Right, XK_ANY_MOD, "\033[C", 0, -1}, | ||
367 | { XK_Right, XK_ANY_MOD, "\033OC", 0, +1}, | ||
368 | { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0}, | ||
369 | { XK_Return, Mod1Mask, "\033\r", 0, 0}, | ||
370 | { XK_Return, XK_ANY_MOD, "\r", 0, 0}, | ||
371 | { XK_Insert, ShiftMask, "\033[4l", -1, 0}, | ||
372 | { XK_Insert, ShiftMask, "\033[2;2~", +1, 0}, | ||
373 | { XK_Insert, ControlMask, "\033[L", -1, 0}, | ||
374 | { XK_Insert, ControlMask, "\033[2;5~", +1, 0}, | ||
375 | { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, | ||
376 | { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, | ||
377 | { XK_Delete, ControlMask, "\033[M", -1, 0}, | ||
378 | { XK_Delete, ControlMask, "\033[3;5~", +1, 0}, | ||
379 | { XK_Delete, ShiftMask, "\033[2K", -1, 0}, | ||
380 | { XK_Delete, ShiftMask, "\033[3;2~", +1, 0}, | ||
381 | { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0}, | ||
382 | { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, | ||
383 | { XK_BackSpace, XK_NO_MOD, "\177", 0, 0}, | ||
384 | { XK_BackSpace, Mod1Mask, "\033\177", 0, 0}, | ||
385 | { XK_Home, ShiftMask, "\033[2J", 0, -1}, | ||
386 | { XK_Home, ShiftMask, "\033[1;2H", 0, +1}, | ||
387 | { XK_Home, XK_ANY_MOD, "\033[H", 0, -1}, | ||
388 | { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1}, | ||
389 | { XK_End, ControlMask, "\033[J", -1, 0}, | ||
390 | { XK_End, ControlMask, "\033[1;5F", +1, 0}, | ||
391 | { XK_End, ShiftMask, "\033[K", -1, 0}, | ||
392 | { XK_End, ShiftMask, "\033[1;2F", +1, 0}, | ||
393 | { XK_End, XK_ANY_MOD, "\033[4~", 0, 0}, | ||
394 | { XK_Prior, ControlMask, "\033[5;5~", 0, 0}, | ||
395 | { XK_Prior, ShiftMask, "\033[5;2~", 0, 0}, | ||
396 | { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, | ||
397 | { XK_Next, ControlMask, "\033[6;5~", 0, 0}, | ||
398 | { XK_Next, ShiftMask, "\033[6;2~", 0, 0}, | ||
399 | { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0}, | ||
400 | { XK_F1, XK_NO_MOD, "\033OP" , 0, 0}, | ||
401 | { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0}, | ||
402 | { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0}, | ||
403 | { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0}, | ||
404 | { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0}, | ||
405 | { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0}, | ||
406 | { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0}, | ||
407 | { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0}, | ||
408 | { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0}, | ||
409 | { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0}, | ||
410 | { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0}, | ||
411 | { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0}, | ||
412 | { XK_F3, XK_NO_MOD, "\033OR" , 0, 0}, | ||
413 | { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0}, | ||
414 | { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0}, | ||
415 | { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0}, | ||
416 | { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0}, | ||
417 | { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0}, | ||
418 | { XK_F4, XK_NO_MOD, "\033OS" , 0, 0}, | ||
419 | { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0}, | ||
420 | { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0}, | ||
421 | { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0}, | ||
422 | { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0}, | ||
423 | { XK_F5, XK_NO_MOD, "\033[15~", 0, 0}, | ||
424 | { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0}, | ||
425 | { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0}, | ||
426 | { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0}, | ||
427 | { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0}, | ||
428 | { XK_F6, XK_NO_MOD, "\033[17~", 0, 0}, | ||
429 | { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0}, | ||
430 | { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0}, | ||
431 | { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0}, | ||
432 | { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0}, | ||
433 | { XK_F7, XK_NO_MOD, "\033[18~", 0, 0}, | ||
434 | { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0}, | ||
435 | { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0}, | ||
436 | { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0}, | ||
437 | { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0}, | ||
438 | { XK_F8, XK_NO_MOD, "\033[19~", 0, 0}, | ||
439 | { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0}, | ||
440 | { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0}, | ||
441 | { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0}, | ||
442 | { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0}, | ||
443 | { XK_F9, XK_NO_MOD, "\033[20~", 0, 0}, | ||
444 | { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0}, | ||
445 | { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0}, | ||
446 | { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0}, | ||
447 | { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0}, | ||
448 | { XK_F10, XK_NO_MOD, "\033[21~", 0, 0}, | ||
449 | { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0}, | ||
450 | { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0}, | ||
451 | { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0}, | ||
452 | { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0}, | ||
453 | { XK_F11, XK_NO_MOD, "\033[23~", 0, 0}, | ||
454 | { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0}, | ||
455 | { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0}, | ||
456 | { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0}, | ||
457 | { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0}, | ||
458 | { XK_F12, XK_NO_MOD, "\033[24~", 0, 0}, | ||
459 | { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0}, | ||
460 | { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0}, | ||
461 | { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0}, | ||
462 | { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0}, | ||
463 | { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0}, | ||
464 | { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0}, | ||
465 | { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0}, | ||
466 | { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0}, | ||
467 | { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0}, | ||
468 | { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0}, | ||
469 | { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0}, | ||
470 | { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0}, | ||
471 | { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0}, | ||
472 | { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0}, | ||
473 | { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0}, | ||
474 | { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0}, | ||
475 | { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0}, | ||
476 | { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0}, | ||
477 | { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0}, | ||
478 | { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0}, | ||
479 | { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0}, | ||
480 | { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0}, | ||
481 | { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0}, | ||
482 | { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0}, | ||
483 | { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0}, | ||
484 | { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0}, | ||
485 | { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0}, | ||
486 | }; | ||
487 | |||
488 | /* | ||
489 | * Selection types' masks. | ||
490 | * Use the same masks as usual. | ||
491 | * Button1Mask is always unset, to make masks match between ButtonPress. | ||
492 | * ButtonRelease and MotionNotify. | ||
493 | * If no match is found, regular selection is used. | ||
494 | */ | ||
495 | static uint selmasks[] = { | ||
496 | [SEL_RECTANGULAR] = Mod1Mask, | ||
497 | }; | ||
498 | |||
499 | /* | ||
500 | * Printable characters in ASCII, used to estimate the advance width | ||
501 | * of single wide characters. | ||
502 | */ | ||
503 | static char ascii_printable[] = | ||
504 | " !\"#$%&'()*+,-./0123456789:;<=>?" | ||
505 | "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" | ||
506 | "`abcdefghijklmnopqrstuvwxyz{|}~"; | ||
507 | |||
diff --git a/programs/tmux.nix b/programs/tmux.nix new file mode 100644 index 0000000..58369da --- /dev/null +++ b/programs/tmux.nix | |||
@@ -0,0 +1,85 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | programs.tmux = { | ||
8 | enable = true; | ||
9 | plugins = with pkgs; [ | ||
10 | tmuxPlugins.fingers | ||
11 | ]; | ||
12 | extraConfig = '' | ||
13 | set -g prefix C-a | ||
14 | setw -g mode-keys vi | ||
15 | unbind-key C-b | ||
16 | bind-key C-a send-prefix | ||
17 | |||
18 | bind r source-file ~/.tmux.conf | ||
19 | |||
20 | set-option -g default-terminal xterm-256color-italic | ||
21 | set escape-time 20 | ||
22 | |||
23 | set -g mouse on | ||
24 | |||
25 | set -g base-index 1 | ||
26 | setw -g pane-base-index 1 | ||
27 | |||
28 | # pane binds | ||
29 | bind-key h select-pane -L | ||
30 | bind-key j select-pane -D | ||
31 | bind-key k select-pane -U | ||
32 | bind-key l select-pane -R | ||
33 | bind-key -r H resize-pane -L 5 | ||
34 | bind-key -r J resize-pane -D 5 | ||
35 | bind-key -r K resize-pane -U 5 | ||
36 | bind-key -r L resize-pane -R 5 | ||
37 | |||
38 | # window binds | ||
39 | bind -n M-h previous-window | ||
40 | bind -n M-l next-window | ||
41 | bind-key "|" split-window -h -c "#{pane_current_path}" | ||
42 | bind-key "-" split-window -v -c "#{pane_current_path}" | ||
43 | bind-key s choose-session | ||
44 | bind-key c new-window -c "#{pane_current_path}" | ||
45 | bind-key ) swap-window -t +1 | ||
46 | bind-key ( swap-window -t -1 | ||
47 | bind-key [ copy-mode | ||
48 | |||
49 | # statusline hide / unhide | ||
50 | bind -n M-down set -q status off | ||
51 | bind -n M-up set -q status on | ||
52 | |||
53 | bind-key -r "<" swap-window -d -t -1 | ||
54 | bind-key -r ">" swap-window -d -t +1 | ||
55 | |||
56 | bind-key -T copy-mode-vi v send-keys -X begin-selection | ||
57 | bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -i -sel p -f | xclip -i -sel c " | ||
58 | bind-key -T copy-mode-vi r send-keys -X rectangle-toggle | ||
59 | bind P paste-buffer | ||
60 | |||
61 | bind E command-prompt -p "Command:" \ | ||
62 | "run \"tmux list-panes -a -F '##{session_name}:##{window_index}.##{pane_index}' \ | ||
63 | | xargs -I PANE tmux send-keys -t PANE '%1' Enter\"" | ||
64 | |||
65 | set-window-option -g allow-rename off | ||
66 | |||
67 | set -g pane-border-style fg=colour11 | ||
68 | set -g pane-active-border-style fg=colour8 | ||
69 | |||
70 | set -g status-justify right | ||
71 | set -g status-right "" | ||
72 | set -g status-style "bg=colour0" | ||
73 | set -ag status-style "fg=colour7" | ||
74 | |||
75 | set -g window-status-current-format " #[fg=colour15]#W#{?window_zoomed_flag, #[fg=colour2]+,}#{?window_activity_flag, #[fg=colour3]!,}" | ||
76 | set -g window-status-format " #[fg=colour8]#W#{?window_zoomed_flag, #[fg=colour2]+,}" | ||
77 | |||
78 | |||
79 | set -g status-left-length 100 | ||
80 | set -g status-left "#[fg=colour15]#(date +"%H%M") #[fg=colour8]hrs " | ||
81 | set -ag status-left "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y") " | ||
82 | set -ag status-left "#[fg=colour7]#(~/scripts/bat -q)#[fg=colour12]" | ||
83 | ''; | ||
84 | }; | ||
85 | } | ||
diff --git a/programs/zathura.nix b/programs/zathura.nix new file mode 100644 index 0000000..5e5c8ce --- /dev/null +++ b/programs/zathura.nix | |||
@@ -0,0 +1,37 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | programs.zathura = { | ||
10 | enable = true; | ||
11 | options = { | ||
12 | incremental-search = "true"; | ||
13 | recolor = "true"; | ||
14 | default-bg = base00; | ||
15 | default-fg = base05; | ||
16 | completion-bg = base00; | ||
17 | completion-fg = base05; | ||
18 | completion-highlight-bg = base0E; | ||
19 | completion-highlight-fg = base05; | ||
20 | statusbar-bg = base00; | ||
21 | statusbar-fg = base05; | ||
22 | inputbar-bg = base00; | ||
23 | inputbar-fg = base05; | ||
24 | recolor-darkcolor = base05; | ||
25 | recolor-lightcolor = base00; | ||
26 | window-height = "800"; | ||
27 | window-width = "600"; | ||
28 | adjust-open = "width"; | ||
29 | smooth-scroll = "true"; | ||
30 | statusbar-home-tilde = "true"; | ||
31 | statusbar-h-padding = "50"; | ||
32 | statusbar-v-padding = "50"; | ||
33 | guioptions = "s"; | ||
34 | font = "Input 10"; | ||
35 | }; | ||
36 | }; | ||
37 | } | ||
diff --git a/scripts/battery.nix b/scripts/battery.nix new file mode 100644 index 0000000..e75116b --- /dev/null +++ b/scripts/battery.nix | |||
@@ -0,0 +1,60 @@ | |||
1 | |||
2 | { pkgs, ...}: | ||
3 | |||
4 | let | ||
5 | name = "bat"; | ||
6 | in | ||
7 | pkgs.writeScriptBin name | ||
8 | '' | ||
9 | red="\e[31m" | ||
10 | grn="\e[32m" | ||
11 | ylw="\e[33m" | ||
12 | cyn="\e[36m" | ||
13 | blu="\e[34m" | ||
14 | prp="\e[35m" | ||
15 | bprp="\e[35;1m" | ||
16 | rst="\e[0m" | ||
17 | |||
18 | bat_status="" | ||
19 | bat_status=$( cat /sys/class/power_supply/BAT0/capacity ) | ||
20 | charging_status=$( cat /sys/class/power_supply/BAT0/status ) | ||
21 | |||
22 | health() { | ||
23 | for i in {0..4} | ||
24 | do | ||
25 | if [[ $i -le $(( $bat_status/20 )) ]]; then | ||
26 | echo -ne "#[fg=colour1]· " | ||
27 | else | ||
28 | echo -ne "#[fg=colour8]· " | ||
29 | fi | ||
30 | done | ||
31 | echo | ||
32 | } | ||
33 | |||
34 | bat_status_small() { | ||
35 | if [[ "$charging_status" = *Charging* ]]; then | ||
36 | echo -ne "+$bat_status%" | ||
37 | else | ||
38 | echo -ne "$bat_status%" | ||
39 | fi | ||
40 | } | ||
41 | |||
42 | [ -z "$1" ] && { | ||
43 | bat_status_small | ||
44 | } | ||
45 | |||
46 | while getopts qi options | ||
47 | do | ||
48 | case $options in | ||
49 | i) | ||
50 | bat_status_small | ||
51 | ;; | ||
52 | q) | ||
53 | if [[ "$charging_status" = *Charging* ]]; then | ||
54 | echo -ne "+ $(health)" | ||
55 | else | ||
56 | health | ||
57 | fi | ||
58 | esac | ||
59 | done | ||
60 | '' | ||
diff --git a/scripts/default.nix b/scripts/default.nix new file mode 100644 index 0000000..84fcff3 --- /dev/null +++ b/scripts/default.nix | |||
@@ -0,0 +1,26 @@ | |||
1 | { pkgs, ... }: | ||
2 | |||
3 | let | ||
4 | |||
5 | # open a window with live video feed from the camera | ||
6 | webcam = pkgs.writeScriptBin "webcam" '' | ||
7 | ${pkgs.mpv}/bin/mpv av://v4l2:/dev/video0 --profile=low-latency --untimed | ||
8 | ''; | ||
9 | |||
10 | # set git repo descriptions on cgit | ||
11 | git-set-desc = pkgs.writeScriptBin "git-set-desc" '' | ||
12 | remote=$(git remote get-url --push origin) | ||
13 | scp .git/description "$remote/description" | ||
14 | ''; | ||
15 | |||
16 | # screen record with ffmpeg and slop | ||
17 | record = import ./record.nix pkgs; | ||
18 | |||
19 | # file uploader | ||
20 | uploader = import ./up.nix pkgs; | ||
21 | |||
22 | # battery script | ||
23 | battery = import ./battery.nix pkgs; | ||
24 | |||
25 | in | ||
26 | [ webcam git-set-desc record uploader battery ] | ||
diff --git a/scripts/record.nix b/scripts/record.nix new file mode 100644 index 0000000..d5bfff5 --- /dev/null +++ b/scripts/record.nix | |||
@@ -0,0 +1,33 @@ | |||
1 | { pkgs, ...}: | ||
2 | |||
3 | let | ||
4 | name = "record"; | ||
5 | slop = "${pkgs.slop}/bin/slop"; | ||
6 | ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg"; | ||
7 | in | ||
8 | pkgs.writeScriptBin name | ||
9 | '' | ||
10 | echo starting recording ... | ||
11 | coords=$(${slop} -f "%x %y %w %h %g %i") || exit 1 | ||
12 | read -r X Y W H G ID < <(echo $coords) | ||
13 | ${ffmpeg} \ | ||
14 | -f x11grab \ | ||
15 | -s "$W"x"$H" \ | ||
16 | -i :0.0+$X,$Y \ | ||
17 | -f alsa \ | ||
18 | -thread_queue_size 512 \ | ||
19 | -ac 2 \ | ||
20 | -ar 48000 \ | ||
21 | -i hw:0 \ | ||
22 | -framerate 60 \ | ||
23 | -vcodec libx264 \ | ||
24 | -threads 4 \ | ||
25 | -y \ | ||
26 | /home/np/tmp/x.mkv | ||
27 | |||
28 | ${ffmpeg} \ | ||
29 | -i /home/np/tmp/x.mkv \ | ||
30 | -pix_fmt yuv420p \ | ||
31 | -vf scale=-2:1080 \ | ||
32 | "/home/np/vids/rec/$1" | ||
33 | '' | ||
diff --git a/scripts/up.nix b/scripts/up.nix new file mode 100644 index 0000000..c4f7c7a --- /dev/null +++ b/scripts/up.nix | |||
@@ -0,0 +1,24 @@ | |||
1 | { pkgs, ... }: | ||
2 | let | ||
3 | name = "up"; | ||
4 | xclip = "${pkgs.xclip}/bin/xclip"; | ||
5 | in | ||
6 | pkgs.writeScriptBin name | ||
7 | '' | ||
8 | id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 3 | head -n 1 ) | ||
9 | |||
10 | if [ $# != 1 ]; then | ||
11 | echo "needs an arg" | ||
12 | else | ||
13 | if [ -f "$1" ]; then | ||
14 | ext="''${1##*.}" | ||
15 | id="$id.$ext" | ||
16 | scp "$1" ferrn:~/www/nerd/uploads/"$id" | ||
17 | echo "https://u.peppe.rs/$id" | ||
18 | echo "https://u.peppe.rs/$id" | ${xclip} -selection clipboard | ||
19 | echo "https://u.peppe.rs/$id" | ${xclip} -i | ||
20 | else | ||
21 | echo "file does not exist" | ||
22 | fi | ||
23 | fi | ||
24 | '' | ||
diff --git a/scripts/webcam.nix b/scripts/webcam.nix new file mode 100644 index 0000000..0658dab --- /dev/null +++ b/scripts/webcam.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | #! /usr/bin/env bash | ||
2 | |||
3 | mpv av://v4l2:/dev/video0 \ | ||
4 | --profile=low-latency \ | ||
5 | --untimed \ | ||
diff --git a/services/battery.nix b/services/battery.nix new file mode 100644 index 0000000..a871e8f --- /dev/null +++ b/services/battery.nix | |||
@@ -0,0 +1,48 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | |||
3 | with lib; | ||
4 | let | ||
5 | cfg = config.services.battery-alert; | ||
6 | bat = pkgs.writeScriptBin "bat" | ||
7 | '' | ||
8 | ''; | ||
9 | in | ||
10 | { | ||
11 | options.services.battery-alert = { | ||
12 | enable = mkOption { | ||
13 | type = types.bool; | ||
14 | default = false; | ||
15 | description = '' | ||
16 | If enabled, NixOS will periodically check battery levels and report | ||
17 | if it is below a threshold value. | ||
18 | ''; | ||
19 | }; | ||
20 | }; | ||
21 | |||
22 | config = { | ||
23 | systemd.user.timers.battery-alert = mkIf cfg.enable { | ||
24 | description = "Periodically check battery status and alert if required"; | ||
25 | timerConfig.OnBootSec = "1m"; | ||
26 | timerConfig.OnUnitInactiveSec = "1m"; | ||
27 | timerConfig.Unit = "battery-alert.service"; | ||
28 | wantedBy = [ "timers.target" ]; | ||
29 | }; | ||
30 | |||
31 | systemd.user.services.battery-alert = { | ||
32 | description = "Check battery levels"; | ||
33 | path = [ pkgs.libnotify pkgs.coreutils ]; | ||
34 | serviceConfig = { | ||
35 | PassEnvironment = "DISPLAY XAUTHORITY"; | ||
36 | }; | ||
37 | script = '' | ||
38 | bat_status=$( ${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity ) | ||
39 | charging_status=$( ${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/status ) | ||
40 | |||
41 | # if [[ $bat_status -ge 10 ]]; then | ||
42 | ${pkgs.libnotify}/bin/notify-send "Battery low: $bat_status%" "$charging_status" | ||
43 | # fi | ||
44 | ''; | ||
45 | }; | ||
46 | |||
47 | }; | ||
48 | } | ||
diff --git a/services/default.nix b/services/default.nix new file mode 100644 index 0000000..0e85cd9 --- /dev/null +++ b/services/default.nix | |||
@@ -0,0 +1,27 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | |||
9 | imports = [ | ||
10 | ./dunst.nix | ||
11 | ./picom.nix | ||
12 | ./redshift.nix | ||
13 | ./sxhkd.nix | ||
14 | ./mbsync.nix | ||
15 | ]; | ||
16 | |||
17 | services = { | ||
18 | lorri.enable = true; | ||
19 | gpg-agent = { | ||
20 | enable = true; | ||
21 | defaultCacheTtl = 86400; | ||
22 | maxCacheTtl = 86400; | ||
23 | pinentryFlavor = "curses"; | ||
24 | }; | ||
25 | }; | ||
26 | |||
27 | } | ||
diff --git a/services/dunst.nix b/services/dunst.nix new file mode 100644 index 0000000..8882ade --- /dev/null +++ b/services/dunst.nix | |||
@@ -0,0 +1,71 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | services.dunst = { | ||
10 | enable = true; | ||
11 | settings = { | ||
12 | global = { | ||
13 | font = "Input 9"; | ||
14 | allow_markup = "no"; | ||
15 | format = "%s\n%b"; | ||
16 | sort = "yes"; | ||
17 | indicate_hidden = "yes"; | ||
18 | alignment = "right"; | ||
19 | bounce_freq = "0"; | ||
20 | show_age_threshold = "60"; | ||
21 | word_wrap = "yes"; | ||
22 | ignore_newline = "no"; | ||
23 | geometry = "300x8-20+20"; | ||
24 | shrink = "yes"; | ||
25 | transparency = "0"; | ||
26 | idle_threshold = "120"; | ||
27 | monitor = "0"; | ||
28 | follow = "mouse"; | ||
29 | sticky_history = "yes"; | ||
30 | history_length = "20"; | ||
31 | show_indicators = "yes"; | ||
32 | line_height = "0"; | ||
33 | separator_height = "0"; | ||
34 | padding = "20"; | ||
35 | horizontal_padding = "20"; | ||
36 | separator_color = "auto"; | ||
37 | startup_notification = "true"; | ||
38 | }; | ||
39 | |||
40 | urgency_normal = { | ||
41 | background = base00; | ||
42 | foreground = base05; | ||
43 | timeout = 10; | ||
44 | }; | ||
45 | |||
46 | urgency_low = { | ||
47 | background = base00; | ||
48 | foreground = base05; | ||
49 | timeout = 2; | ||
50 | }; | ||
51 | |||
52 | urgency_critical = { | ||
53 | background = base00; | ||
54 | foreground = base05; | ||
55 | timeout = 0; | ||
56 | }; | ||
57 | |||
58 | frame = { | ||
59 | width = 2; | ||
60 | color = base01; | ||
61 | }; | ||
62 | |||
63 | shortcuts = { | ||
64 | close = "ctrl+space"; | ||
65 | close_all = "ctrl+shift+space"; | ||
66 | history = "ctrl+grave"; | ||
67 | context = "ctrl+shift+period"; | ||
68 | }; | ||
69 | }; | ||
70 | }; | ||
71 | } | ||
diff --git a/services/mbsync.nix b/services/mbsync.nix new file mode 100644 index 0000000..168b7ec --- /dev/null +++ b/services/mbsync.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | services.mbsync = { | ||
8 | enable = true; | ||
9 | frequency = "*:0/15"; | ||
10 | }; | ||
11 | } | ||
diff --git a/services/picom.nix b/services/picom.nix new file mode 100644 index 0000000..67605d1 --- /dev/null +++ b/services/picom.nix | |||
@@ -0,0 +1,18 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | services.picom = { | ||
8 | enable = true; | ||
9 | backend = "glx"; | ||
10 | fade = true; | ||
11 | fadeDelta = 10; | ||
12 | fadeSteps = [ "0.04" "0.04" ]; | ||
13 | inactiveDim = "0.0"; | ||
14 | shadow = false; | ||
15 | shadowOffsets = [ (-60) (-60) ]; | ||
16 | shadowOpacity = "0.20"; | ||
17 | }; | ||
18 | } | ||
diff --git a/services/redshift.nix b/services/redshift.nix new file mode 100644 index 0000000..5385fc1 --- /dev/null +++ b/services/redshift.nix | |||
@@ -0,0 +1,18 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | services.redshift = { | ||
8 | enable = true; | ||
9 | temperature = { | ||
10 | day = 5000; | ||
11 | night = 4000; | ||
12 | }; | ||
13 | tray = false; | ||
14 | provider = "manual"; | ||
15 | latitude = "12"; | ||
16 | longitude = "77"; | ||
17 | }; | ||
18 | } | ||
diff --git a/services/suspend.nix b/services/suspend.nix new file mode 100644 index 0000000..445446b --- /dev/null +++ b/services/suspend.nix | |||
@@ -0,0 +1,65 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | |||
3 | with lib; | ||
4 | let | ||
5 | cfg = config.services.batteryNotifier; | ||
6 | in | ||
7 | { | ||
8 | options = { | ||
9 | services.batteryNotifier = { | ||
10 | enable = mkOption { | ||
11 | default = false; | ||
12 | description = '' | ||
13 | Whether to enable battery notifier. | ||
14 | ''; | ||
15 | }; | ||
16 | device = mkOption { | ||
17 | default = "BAT0"; | ||
18 | description = '' | ||
19 | Device to monitor. | ||
20 | ''; | ||
21 | }; | ||
22 | notifyCapacity = mkOption { | ||
23 | default = 10; | ||
24 | description = '' | ||
25 | Battery level at which a notification shall be sent. | ||
26 | ''; | ||
27 | }; | ||
28 | suspendCapacity = mkOption { | ||
29 | default = 5; | ||
30 | description = '' | ||
31 | Battery level at which a suspend unless connected shall be sent. | ||
32 | ''; | ||
33 | }; | ||
34 | }; | ||
35 | }; | ||
36 | |||
37 | config = mkIf cfg.enable { | ||
38 | systemd.user.timers."lowbatt" = { | ||
39 | description = "check battery level"; | ||
40 | timerConfig.OnBootSec = "1m"; | ||
41 | timerConfig.OnUnitInactiveSec = "1m"; | ||
42 | timerConfig.Unit = "lowbatt.service"; | ||
43 | wantedBy = [ "timers.target" ]; | ||
44 | }; | ||
45 | systemd.user.services."lowbatt" = { | ||
46 | description = "battery level notifier"; | ||
47 | serviceConfig.PassEnvironment = "DISPLAY"; | ||
48 | script = '' | ||
49 | export battery_capacity=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/capacity) | ||
50 | export battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) | ||
51 | if [[ $battery_capacity -le ${builtins.toString cfg.notifyCapacity} && $battery_status = "Discharging" ]]; then | ||
52 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Low" "You should probably plug-in." | ||
53 | fi | ||
54 | if [[ $battery_capacity -le ${builtins.toString cfg.suspendCapacity} && $battery_status = "Discharging" ]]; then | ||
55 | ${pkgs.libnotify}/bin/notify-send --urgency=critical --hint=int:transient:1 --icon=battery_empty "Battery Critically Low" "Computer will suspend in 60 seconds." | ||
56 | sleep 60s | ||
57 | battery_status=$(${pkgs.coreutils}/bin/cat /sys/class/power_supply/${cfg.device}/status) | ||
58 | if [[ $battery_status = "Discharging" ]]; then | ||
59 | systemctl suspend | ||
60 | fi | ||
61 | fi | ||
62 | ''; | ||
63 | }; | ||
64 | }; | ||
65 | } | ||
diff --git a/services/sxhkd.nix b/services/sxhkd.nix new file mode 100644 index 0000000..8658875 --- /dev/null +++ b/services/sxhkd.nix | |||
@@ -0,0 +1,17 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | services.sxhkd = { | ||
9 | enable = true; | ||
10 | keybindings = { | ||
11 | "XF86Audio{Lower,Raise}Volume" = "${pkgs.alsaUtils}/bin/amixer sset Master 2%{-,+}"; | ||
12 | "XF86AudioMute" = "${pkgs.alsaUtils}/bin/amixer sset Master toggle"; | ||
13 | "XF86MonBrightness{Down,Up}" = "${pkgs.light}/bin/light -{U,A} 5"; | ||
14 | "super + Escape" = "pkill -USR1 -x sxhkd"; | ||
15 | }; | ||
16 | }; | ||
17 | } | ||
diff --git a/theme.nix b/theme.nix new file mode 100644 index 0000000..24a8dac --- /dev/null +++ b/theme.nix | |||
@@ -0,0 +1,39 @@ | |||
1 | let | ||
2 | day = { | ||
3 | base00 = "#fafafa"; | ||
4 | base01 = "#f0f0f1"; | ||
5 | base02 = "#e5e5e6"; | ||
6 | base03 = "#a0a1a7"; | ||
7 | base04 = "#696c77"; | ||
8 | base05 = "#383a42"; | ||
9 | base06 = "#202227"; | ||
10 | base07 = "#090a0b"; | ||
11 | base08 = "#ca1243"; | ||
12 | base09 = "#d75f00"; | ||
13 | base0A = "#c18401"; | ||
14 | base0B = "#50a14f"; | ||
15 | base0C = "#29BC9B"; | ||
16 | base0D = "#4078f2"; | ||
17 | base0E = "#EB367F"; | ||
18 | base0F = "#986801"; | ||
19 | }; | ||
20 | night = { | ||
21 | base00 = "#000000"; | ||
22 | base01 = "#303030"; | ||
23 | base02 = "#353535"; | ||
24 | base03 = "#4A4A4A"; | ||
25 | base04 = "#787878"; | ||
26 | base05 = "#EEFFFF"; | ||
27 | base06 = "#EEFFFF"; | ||
28 | base07 = "#FFFFFF"; | ||
29 | base08 = "#F07178"; | ||
30 | base09 = "#F78C6C"; | ||
31 | base0A = "#FDF200"; | ||
32 | base0B = "#13CA91"; | ||
33 | base0C = "#79ffe1"; | ||
34 | base0D = "#7898FB"; | ||
35 | base0E = "#ff3299"; | ||
36 | base0F = "#FF5370"; | ||
37 | }; | ||
38 | in | ||
39 | night | ||
diff --git a/x/2bwm.nix b/x/2bwm.nix new file mode 100644 index 0000000..09d1a0c --- /dev/null +++ b/x/2bwm.nix | |||
@@ -0,0 +1,20 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | xresources.properties = { | ||
10 | "twobwm.border_width" = 8; | ||
11 | "twobwm.outer_border" = 2; | ||
12 | "twobwm.focus_color" = base01; | ||
13 | "twobwm.unfocus_color" = base01; | ||
14 | "twobwm.fixed_color" = base0D; | ||
15 | "twobwm.unkill_color" = base08; | ||
16 | "twobwm.fixed_unkill_color" = base0E; | ||
17 | "twobwm.outer_border_color" = base00; | ||
18 | "twobwm.inverted_colors" = true; | ||
19 | }; | ||
20 | } | ||
diff --git a/x/default.nix b/x/default.nix new file mode 100644 index 0000000..cd64f61 --- /dev/null +++ b/x/default.nix | |||
@@ -0,0 +1,14 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | { | ||
8 | imports = [ | ||
9 | ./2bwm.nix | ||
10 | ./xft.nix | ||
11 | ./rofi.nix | ||
12 | ./rxvt.nix | ||
13 | ]; | ||
14 | } | ||
diff --git a/x/rofi.nix b/x/rofi.nix new file mode 100644 index 0000000..ff80b05 --- /dev/null +++ b/x/rofi.nix | |||
@@ -0,0 +1,30 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | xresources.properties = { | ||
10 | "rofi.color-enabled" = true; | ||
11 | |||
12 | "rofi.color-window" = "${base00}, ${base00}, ${base00}, ${base00}, ${base03}"; | ||
13 | "rofi.color-normal" = "${base00}, ${base03}, ${base00}, ${base00}, ${base07}"; | ||
14 | "rofi.color-active" = "${base03}, ${base0E}, ${base00}, ${base0B}, ${base00}"; | ||
15 | "rofi.color-urgent" = "${base00}, ${base03}, ${base00}, ${base00}, ${base03}"; | ||
16 | |||
17 | "rofi.fake-transparency" = true; | ||
18 | "rofi.font" = "Input 13"; | ||
19 | "rofi.columns" = 1; | ||
20 | "rofi.separator-style" = "none"; | ||
21 | "rofi.hide-scrollbar" = true; | ||
22 | "rofi.location" = 1; | ||
23 | "rofi.yoffset" = 20; | ||
24 | "rofi.xoffset" = 20; | ||
25 | "rofi.padding" = 32; | ||
26 | "rofi.fullscreen" = false; | ||
27 | "rofi.width" = 300; | ||
28 | "rofi.lines" = 6; | ||
29 | }; | ||
30 | } | ||
diff --git a/x/rxvt.nix b/x/rxvt.nix new file mode 100644 index 0000000..3498bd0 --- /dev/null +++ b/x/rxvt.nix | |||
@@ -0,0 +1,58 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , theme | ||
4 | , ... | ||
5 | }: | ||
6 | |||
7 | with theme; | ||
8 | { | ||
9 | xresources.properties = { | ||
10 | "*foreground" = base05; | ||
11 | "*background" = base00; | ||
12 | "*cursorColor" = base05; | ||
13 | |||
14 | "*color0" = base00; | ||
15 | "*color1" = base08; | ||
16 | "*color2" = base0B; | ||
17 | "*color3" = base0A; | ||
18 | "*color4" = base0D; | ||
19 | "*color5" = base0E; | ||
20 | "*color6" = base0C; | ||
21 | "*color7" = base05; | ||
22 | |||
23 | "*color8" = base03; | ||
24 | "*color9" = base09; | ||
25 | "*color10" = base01; | ||
26 | "*color11" = base02; | ||
27 | "*color12" = base04; | ||
28 | "*color13" = base06; | ||
29 | "*color14" = base0F; | ||
30 | "*color15" = base07; | ||
31 | |||
32 | "*.cursorBlink" = "on"; | ||
33 | "URxvt.font" = "xft:Nerd Input:size=11:style=Medium"; | ||
34 | "URxvt.italicFont" = "xft:Nerd Input:size=11:style=Medium"; | ||
35 | "URxvt.boldFont" = "xft:Nerd Input:size=11:style=Medium"; | ||
36 | "*font" = "Nerd Input:size=11:style=Regular"; | ||
37 | "*italicFont" = "Nerd Input:size=11:style=Italic"; | ||
38 | "*boldFont" = "Nerd Input:size=11:style=Bold"; | ||
39 | |||
40 | "URxvt.lineSpace" = 0; | ||
41 | "URxvt.letterSpace" = 0; | ||
42 | "URxvt.scrollBar" = false; | ||
43 | "URxvt.internalBorder" = 25; | ||
44 | "URxvt.cursorUnderline" = false; | ||
45 | "URxvt.geometry" = "70x35"; | ||
46 | "URxvt.thickness" = 5; | ||
47 | "URxvt.titleBar" = false; | ||
48 | "URxvt.intensityStyles" = false; | ||
49 | |||
50 | |||
51 | "*.perl-ext-common" = "default,matcher,font-size"; | ||
52 | "URxvt.keysym.C-Up" = "perl:font-size:increase"; | ||
53 | "URxvt.keysym.C-Down" = "perl:font-size:decrease"; | ||
54 | "URxvt.keysym.C-equal" = "perl:font-size:reset"; | ||
55 | "*.url-launcher" = "firefox"; | ||
56 | "*.matcher.button" = 1; | ||
57 | }; | ||
58 | } | ||
diff --git a/x/xft.nix b/x/xft.nix new file mode 100644 index 0000000..74ea87d --- /dev/null +++ b/x/xft.nix | |||
@@ -0,0 +1,16 @@ | |||
1 | { config | ||
2 | , pkgs | ||
3 | , ... | ||
4 | }: | ||
5 | |||
6 | { | ||
7 | xresources.properties = { | ||
8 | "Xft.autohint" = 1; | ||
9 | "Xft.antialias" = 1; | ||
10 | "Xft.lcdfilter" = "lcddefault"; | ||
11 | "Xft.hintstyle" = "hintslight"; | ||
12 | "Xft.hinting" = true; | ||
13 | "Xft.rgba" = "rgb"; | ||
14 | "Xft.dpi" = 110; | ||
15 | }; | ||
16 | } | ||