Skip to content

Commit

Permalink
feat: Update tmux
Browse files Browse the repository at this point in the history
  • Loading branch information
heraldofsolace committed Jan 17, 2024
1 parent f100bd4 commit efb8fab
Show file tree
Hide file tree
Showing 31 changed files with 346 additions and 154 deletions.
10 changes: 5 additions & 5 deletions cells/common/packages/hass-report-usage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ writeShellApplication {
fi
fi
trap "rm /dev/shm/in_use; curl --header \"Content-Type: application/json\" --request POST --data '{\"in_use\": 'false'}' http://hass:8123/api/webhook/eaea48a1-30e3-47bf-a076-30f816f0d3d1" EXIT
trap 'rm /dev/shm/in_use; curl --header "Content-Type: application/json" --request POST --data "{\"in_use\": \"false\"}" "$1"' EXIT
echo $$ > /dev/shm/in_use.pid
Expand All @@ -22,8 +22,8 @@ writeShellApplication {
# Store a timestamp 10 minutes in the past, to trigger an immediate update.
echo $(( $(date +%s%3N) - 600000)) > /dev/shm/in_use.timestamp
# Consider computer idle after 5 minutes.
TIMEOUT=300000
# Consider computer idle after 3 minutes.
TIMEOUT=180000
while true; do
if [ "$(xprintidle)" -lt $TIMEOUT ]; then
Expand All @@ -32,7 +32,7 @@ writeShellApplication {
IN_USE=false
fi
# Report every 5 minutes.
# Report every 3 minutes.
if [ "$(date +%s%3N)" -gt $(( $(cat /dev/shm/in_use.timestamp) + TIMEOUT)) ]; then
REPORT=true
else
Expand All @@ -48,7 +48,7 @@ writeShellApplication {
if $REPORT || $CHANGED; then
echo $IN_USE > /dev/shm/in_use
date +%s%3N > /dev/shm/in_use.timestamp
curl --header "Content-Type: application/json" --request POST --data '{"in_use": '$IN_USE'}' http://hass:8123/api/webhook/eaea48a1-30e3-47bf-a076-30f816f0d3d1
curl --header "Content-Type: application/json" --request POST --data '{"in_use": '$IN_USE'}' "$1"
fi
sleep 0.2
Expand Down
75 changes: 64 additions & 11 deletions cells/common/packages/siril-new2.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
{ lib, stdenv, fetchFromGitLab, fetchpatch, pkg-config, meson, ninja, cmake
, git, criterion, gtk3, libconfig, gnuplot, opencv, json-glib
, fftwFloat, cfitsio, gsl, exiv2, librtprocess, wcslib, ffmpeg
, libraw, libtiff, libpng, libjpeg, libheif, ffms, wrapGAppsHook
, glib-networking, curl, ...
{
lib,
stdenv,
fetchFromGitLab,
fetchpatch,
pkg-config,
meson,
ninja,
cmake,
git,
criterion,
gtk3,
libconfig,
gnuplot,
opencv,
json-glib,
fftwFloat,
cfitsio,
gsl,
exiv2,
librtprocess,
wcslib,
ffmpeg,
libraw,
libtiff,
libpng,
libjpeg,
libheif,
ffms,
wrapGAppsHook,
glib-networking,
curl,
...
}:

stdenv.mkDerivation rec {
pname = "siril-new2";
version = "1.2.0";
Expand All @@ -25,12 +52,38 @@ stdenv.mkDerivation rec {
];

nativeBuildInputs = [
meson ninja cmake pkg-config git criterion wrapGAppsHook glib-networking curl
meson
ninja
cmake
pkg-config
git
criterion
wrapGAppsHook
glib-networking
curl
];

buildInputs = [
gtk3 cfitsio gsl exiv2 gnuplot opencv fftwFloat librtprocess wcslib
libconfig libraw libtiff libpng libjpeg libheif ffms ffmpeg json-glib glib-networking curl
gtk3
cfitsio
gsl
exiv2
gnuplot
opencv
fftwFloat
librtprocess
wcslib
libconfig
libraw
libtiff
libpng
libjpeg
libheif
ffms
ffmpeg
json-glib
glib-networking
curl
];

# Necessary because project uses default build dir for flatpaks/snaps
Expand All @@ -50,7 +103,7 @@ stdenv.mkDerivation rec {
description = "Astrophotographic image processing tool";
license = licenses.gpl3Plus;
changelog = "https://gitlab.com/free-astro/siril/-/blob/HEAD/ChangeLog";
maintainers = with maintainers; [ hjones2199 ];
maintainers = with maintainers; [hjones2199];
platforms = platforms.linux;
};
}
}
52 changes: 52 additions & 0 deletions cells/common/packages/tmx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
writeShellApplication,
tmux,
...
}:
writeShellApplication {
name = "tmx";
runtimeInputs = [tmux];
text = ''
#!/usr/bin/env bash
# Modified TMUX start script from:
# http://forums.gentoo.org/viewtopic-t-836006-start-0.html
set +u
# Works because bash automatically trims by assigning to variables and by passing arguments
trim() { echo "$1"; }
if [[ -z "$1" ]]; then
echo "Specify session name as the first argument"
exit
fi
# Only because I often issue `ls` to this script by accident
if [[ "$1" == "ls" ]]; then
tmux ls
exit
fi
base_session="$1"
# This actually works without the trim() on all systems except OSX
tmux_nb=$(trim "$(tmux ls | grep -c ^"""$base_session""" )")
if [[ "$tmux_nb" == "0" ]]; then
echo "Launching tmux base session $base_session ..."
tmux new-session -s "$base_session"
else
# Make sure we are not already in a tmux session
if [[ -z "$TMUX" ]]; then
echo "Launching copy of base session $base_session ..."
# Session id is date and time to prevent conflict
session_id=$(date +%Y%m%d%H%M%S)
# Create a new session (without attaching it) and link to base session
# to share windows
tmux new-session -d -t "$base_session" -s "$session_id"
if [[ "$2" == "1" ]]; then
# Create a new window in that session
tmux new-window
fi
# Attach to the new session & kill it once orphaned
tmux attach-session -t "$session_id" \; set-option destroy-unattached
fi
fi
'';
}
2 changes: 0 additions & 2 deletions cells/common/packages/transmissionic-web.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ stdenvNoCC.mkDerivation rec {
license = licenses.mit;
};
}
#

5 changes: 5 additions & 0 deletions cells/common/packages/xdg-desktop-portal.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{xdg-desktop-portal, ...}:
xdg-desktop-portal.overrideAttrs (o: rec {
mesonFlags = o.mesonFlags ++ ["-Dpytest=disabled"];
doCheck = false;
})
39 changes: 39 additions & 0 deletions cells/home/homeModules/hass-report-usage.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.services.hass-report-usage;
in {
options.services.hass-report-usage = {
enable = lib.mkEnableOption "Enable hass-report-usage";

url = lib.mkOption {
type = lib.types.str;
description = "URL to report to";
example = "http://192.168.0.3:8123/api/webhook/eaea48a1-30e3-47bf-a076-30f816f0d3d1";
default = "http://192.168.0.3:8123/api/webhook/eaea48a1-30e3-47bf-a076-30f816f0d3d1";
};

package = lib.mkPackageOption pkgs "hass-report-usage" {};
};

config = lib.mkIf cfg.enable {
home.packages = [pkgs.xdotool];
systemd.user.services.hass-report-usage = {
Unit = {
Description = "Hass report usage";
};

Service = {
Type = "simple";
ExecStart = "${lib.getExe cfg.package} ${lib.escapeShellArg cfg.url}";
Restart = "on-failure";
RestartSec = 1;
};

Install.WantedBy = ["default.target"];
};
};
}
2 changes: 1 addition & 1 deletion cells/home/profiles/audio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ _: {pkgs, ...}: {
alsa-scarlett-gui
bitwig-studio
];
}
}
23 changes: 22 additions & 1 deletion cells/home/profiles/editors/_files/vscode-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,26 @@
"files.autoSaveDelay": 1000,
"workbench.iconTheme": "vscode-icons",
"vsicons.dontShowNewVersionMessage": true,
"editor.inlineSuggest.enabled": true
"editor.inlineSuggest.enabled": true,
"[nix]": {
"editor.formatOnSave": true
},
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform",
"editor.formatOnSave": true
},
"nix.enableLanguageServer": true,
"nix.serverPath": "nil",
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["alejandra"]
}
}
},
"terraform.codelens.referenceCount": true,
"terraform.experimentalFeatures.prefillRequiredFields": true,
"terraform.experimentalFeatures.validateOnSave": true,
"vscode-kubernetes.log-viewer.follow": true,
"window.zoomLevel": 1
}
2 changes: 1 addition & 1 deletion cells/home/profiles/editors/vscode-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
services.vscode-server = {
enable = true;
};
}
}
50 changes: 27 additions & 23 deletions cells/home/profiles/misc/keyboard.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
_: {pkgs, lib, ...}: {
home.packages = with pkgs; [
wally-cli
via
vial
bazecor
kanata
_: {
pkgs,
lib,
...
}: {
home.packages = with pkgs; [
wally-cli
via
vial
bazecor
kanata
];

# [Unit]
# Description=Kanata keyboard remapper
# Documentation=https://github.com/jtroo/kanata

# [Unit]
# Description=Kanata keyboard remapper
# Documentation=https://github.com/jtroo/kanata
# [Service]
# Environment=PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin
# Environment=DISPLAY=:0
# Environment=HOME=/path/to/home/folder
# Type=simple
# ExecStart=/usr/local/bin/kanata --cfg /path/to/kanata/config/file
# Restart=never

# [Service]
# Environment=PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin
# Environment=DISPLAY=:0
# Environment=HOME=/path/to/home/folder
# Type=simple
# ExecStart=/usr/local/bin/kanata --cfg /path/to/kanata/config/file
# Restart=never

# [Install]
# WantedBy=default.target
systemd.user.services.kanata = let configFile = pkgs.writeText "kanata.cfg" (builtins.readFile ./_files/kanata.kbd); in
{
# [Install]
# WantedBy=default.target
systemd.user.services.kanata = let
configFile = pkgs.writeText "kanata.cfg" (builtins.readFile ./_files/kanata.kbd);
in {
Unit = {
Description = "Kanata keyboard remapper";
Documentation = "https://github.com/jtroo/kanata";
Expand All @@ -33,7 +37,7 @@ _: {pkgs, lib, ...}: {
ExecStart = "${pkgs.kanata}/bin/kanata --cfg ${configFile}";
Restart = "no";
Environment = [
"PATH=${lib.makeBinPath [ pkgs.coreutils pkgs.kanata ]}"
"PATH=${lib.makeBinPath [pkgs.coreutils pkgs.kanata]}"
"DISPLAY=:0"
];
};
Expand Down
20 changes: 13 additions & 7 deletions cells/home/profiles/shell/_files/fishPlugins/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@ pkgs: {
plugin-bang-bang = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-bang-bang";
rev = "f969c618301163273d0a03d002614d9a81952c1e";
sha256 = "A8ydBX4LORk+nutjHurqNNWFmW6LIiBPQcxS3x4nbeQ=";
rev = "ec991b80ba7d4dda7a962167b036efc5c2d79419";
hash = "sha256-oPPCtFN2DPuM//c48SXb4TrFRjJtccg0YPXcAo0Lxq0=";
};
plugin-thefuck = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-thefuck";
rev = "6c9a926d045dc404a11854a645917b368f78fc4d";
sha256 = "9MbkyEsMsZH+3ct7qJSPvLeLRfVkDEkXRTdg/Rhe0dg=";
hash = "sha256-9MbkyEsMsZH+3ct7qJSPvLeLRfVkDEkXRTdg/Rhe0dg=";
};
plugin-foreign-env = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-foreign-env";
rev = "b3dd471bcc885b597c3922e4de836e06415e52dd";
sha256 = "3h03WQrBZmTXZLkQh1oVyhv6zlyYsSDS7HTHr+7WjY8=";
rev = "7f0cf099ae1e1e4ab38f46350ed6757d54471de7";
hash = "sha256-4+k5rSoxkTtYFh/lEjhRkVYa2S4KEzJ/IJbyJl+rJjQ=";
};
plugin-gi = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-gi";
rev = "48bc41a86c5dcf14ffe3745a7f61cba728a4de0c";
sha256 = "njrOCUaWVj+CIZTUzRGrG4yxcEONEl2fpYuXZrAd4qg=";
hash = "sha256-njrOCUaWVj+CIZTUzRGrG4yxcEONEl2fpYuXZrAd4qg=";
};
fish-ssh-agent = pkgs.fetchFromGitHub {
owner = "danhper";
repo = "fish-ssh-agent";
rev = "fd70a2afdd03caf9bf609746bf6b993b9e83be57";
sha256 = "e94Sd1GSUAxwLVVo5yR6msq0jZLOn2m+JZJ6mvwQdLs=";
hash = "sha256-e94Sd1GSUAxwLVVo5yR6msq0jZLOn2m+JZJ6mvwQdLs=";
};
fish-kill-on-port = pkgs.fetchFromGitHub {
owner = "vincentjames501";
repo = "fish-kill-on-port";
rev = "eb91062e5f5356ef63c6fff77f54fd10c027378e";
hash = "sha256-rJ/HJsMhQYcRwcbSOacFjJsZOGfP3A2p3sAOx0zIAXY=";
};
}
1 change: 1 addition & 0 deletions cells/home/profiles/shell/_files/fishPlugins/pluginNames
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ oh-my-fish plugin-thefuck
oh-my-fish plugin-foreign-env
oh-my-fish plugin-gi
danhper fish-ssh-agent
vincentjames501 fish-kill-on-port
Loading

0 comments on commit efb8fab

Please sign in to comment.