aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--home.nix3
-rw-r--r--hosts/myrtle/configuration.nix20
-rw-r--r--programs/bash.nix3
-rw-r--r--scripts/default.nix6
-rw-r--r--scripts/monitor-to-monitor.nix82
-rw-r--r--services/default.nix2
6 files changed, 101 insertions, 15 deletions
diff --git a/home.nix b/home.nix
index f946df1..9880d42 100644
--- a/home.nix
+++ b/home.nix
@@ -30,7 +30,6 @@
30 xclip 30 xclip
31 ripgrep 31 ripgrep
32 miniserve 32 miniserve
33 rnix-lsp
34 pfetch 33 pfetch
35 st 34 st
36 cmus 35 cmus
@@ -54,7 +53,6 @@
54 53
55 # gaming 54 # gaming
56 mgba 55 mgba
57 yuzu
58 56
59 # sync 57 # sync
60 rtorrent 58 rtorrent
@@ -87,7 +85,6 @@
87 # input 85 # input
88 xinput_calibrator 86 xinput_calibrator
89 libinput 87 libinput
90 talon
91 88
92 # meta 89 # meta
93 nixpkgs-review 90 nixpkgs-review
diff --git a/hosts/myrtle/configuration.nix b/hosts/myrtle/configuration.nix
index dd45d3b..afec6b7 100644
--- a/hosts/myrtle/configuration.nix
+++ b/hosts/myrtle/configuration.nix
@@ -71,16 +71,6 @@
71 71
72 xdotool 72 xdotool
73 ]; 73 ];
74 etc = {
75 "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
76 bluez_monitor.properties = {
77 ["bluez5.enable-sbc-xq"] = true,
78 ["bluez5.enable-msbc"] = true,
79 ["bluez5.enable-hw-volume"] = true,
80 ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
81 }
82 '';
83 };
84 }; 74 };
85 75
86 76
@@ -183,6 +173,16 @@
183 alsa.enable = true; 173 alsa.enable = true;
184 alsa.support32Bit = true; 174 alsa.support32Bit = true;
185 pulse.enable = true; 175 pulse.enable = true;
176 wireplumber.configPackages = [
177 (pkgs.writeTextDir "share/wireplumber/bluetooth.lua.d/51-bluez-config.lua" ''
178 bluez_monitor.properties = {
179 ["bluez5.enable-sbc-xq"] = true,
180 ["bluez5.enable-msbc"] = true,
181 ["bluez5.enable-hw-volume"] = true,
182 ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
183 }
184 '')
185 ];
186 }; 186 };
187 187
188 signald = { 188 signald = {
diff --git a/programs/bash.nix b/programs/bash.nix
index e2b825a..7d3c25e 100644
--- a/programs/bash.nix
+++ b/programs/bash.nix
@@ -30,7 +30,8 @@
30 gb = "git branch -v"; 30 gb = "git branch -v";
31 gc = "git commit --verbose"; 31 gc = "git commit --verbose";
32 gd = "git diff --minimal"; 32 gd = "git diff --minimal";
33 ggp = "git push"; 33 gp = "git push";
34 gpf = "git push --force-with-lease";
34 gl = "git log -p --abbrev-commit --pretty=medium"; 35 gl = "git log -p --abbrev-commit --pretty=medium";
35 glo = "git log --pretty=oneline --abbrev-commit"; 36 glo = "git log --pretty=oneline --abbrev-commit";
36 gst = "git status --short"; 37 gst = "git status --short";
diff --git a/scripts/default.nix b/scripts/default.nix
index 616be1c..c7a485c 100644
--- a/scripts/default.nix
+++ b/scripts/default.nix
@@ -39,6 +39,9 @@ let
39 # run-on-gpu script 39 # run-on-gpu script
40 nvidia-offload = import ./nvidia-offload.nix pkgs; 40 nvidia-offload = import ./nvidia-offload.nix pkgs;
41 41
42 # move window to next monitor
43 m2m = import ./monitor-to-monitor.nix pkgs;
44
42 # fzf script to switch between tmux sessions 45 # fzf script to switch between tmux sessions
43 tmux-fzf = pkgs.writeScriptBin "tmux-fzf" '' 46 tmux-fzf = pkgs.writeScriptBin "tmux-fzf" ''
44 LIST_DATA="#{session_name}/#{window_name}/#{pane_current_command} @ #{pane_current_path}" 47 LIST_DATA="#{session_name}/#{window_name}/#{pane_current_command} @ #{pane_current_path}"
@@ -67,6 +70,8 @@ let
67 ${pkgs.xorg.xinput}/bin/xinput set-prop "${stylus}" --type=float "Coordinate Transformation Matrix" ${landscape-transform} 70 ${pkgs.xorg.xinput}/bin/xinput set-prop "${stylus}" --type=float "Coordinate Transformation Matrix" ${landscape-transform}
68 ''; 71 '';
69 72
73
74
70in 75in
71[ 76[
72 webcam 77 webcam
@@ -79,4 +84,5 @@ in
79 portrait 84 portrait
80 landscape 85 landscape
81 nvidia-offload 86 nvidia-offload
87 m2m
82] 88]
diff --git a/scripts/monitor-to-monitor.nix b/scripts/monitor-to-monitor.nix
new file mode 100644
index 0000000..fa03916
--- /dev/null
+++ b/scripts/monitor-to-monitor.nix
@@ -0,0 +1,82 @@
1{ pkgs, ... }:
2
3let
4 name = "m2m";
5in
6pkgs.writeShellScriptBin name ''
7 #
8 # Move the current window to the next monitor.
9 #
10 # Also works only on one X screen (which is the most common case).
11 #
12 # Props to
13 # http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/
14 #
15 # Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and
16 # checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as
17 # the first command does not respect panel/decoration offsets and the second
18 # will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo".
19
20 screen_width=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f1)
21 screen_height=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f2)
22 display_width=$(xdotool getdisplaygeometry | cut -d" " -f1)
23 display_height=$(xdotool getdisplaygeometry | cut -d" " -f2)
24 window_id=$(xdotool getactivewindow)
25
26 # Remember if it was maximized.
27 window_horz_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_HORZ')
28 window_vert_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_VERT')
29
30 # Un-maximize current window so that we can move it
31 wmctrl -ir "$window_id" -b remove,maximized_vert,maximized_horz
32
33 # Read window position
34 x=$(xwininfo -id "$window_id" | awk '/Absolute upper-left X:/ { print $4 }')
35 y=$(xwininfo -id "$window_id" | awk '/Absolute upper-left Y:/ { print $4 }')
36
37 # Subtract any offsets caused by panels or window decorations
38 x_offset=$(xwininfo -id "$window_id" | awk '/Relative upper-left X:/ { print $4 }')
39 y_offset=$(xwininfo -id "$window_id" | awk '/Relative upper-left Y:/ { print $4 }')
40 x=$(( x - x_offset))
41 y=$(( y - y_offset))
42
43 # Compute new X position
44 new_x=$((x + display_width))
45 # Compute new Y position
46 new_y=$((y + display_height))
47
48 # If we would move off the right-most monitor, we set it to the left one.
49 # We also respect the window's width here: moving a window off more than half its width won't happen.
50 width=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1)
51 if [ "$(( new_x + width / 2))" -gt "$screen_width" ]; then
52 new_x=$((new_x - screen_width))
53 fi
54
55 height=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f2)
56 if [ "$((new_y + height / 2))" -gt "$screen_height" ]; then
57 new_y=$((new_y - screen_height))
58 fi
59
60 # Don't move off the left side.
61 if [ "$new_x" -lt 0 ]; then
62 new_x=0
63 fi
64
65 # Don't move off the bottom
66 if [ "$new_y" -lt 0 ]; then
67 new_y=0
68 fi
69
70 # Move the window
71 xdotool windowmove "$window_id" "$new_x" "$new_y"
72
73 # Maximize window again, if it was before
74 if [ -n "''${window_horz_maxed}" ] && [ -n "''${window_vert_maxed}" ]; then
75 wmctrl -ir "$window_id" -b add,maximized_vert,maximized_horz
76 elif [ -n "''${window_horz_maxed}" ]; then
77 wmctrl -ir "$window_id" -b add,maximized_horz
78 elif [ -n "''${window_vert_maxed}" ]; then
79 wmctrl -ir "$window_id" -b add,maximized_vert
80 fi
81''
82
diff --git a/services/default.nix b/services/default.nix
index 0a3977d..bef7c85 100644
--- a/services/default.nix
+++ b/services/default.nix
@@ -21,7 +21,7 @@
21 enable = true; 21 enable = true;
22 defaultCacheTtl = 60 * 60 * 24 * 7; 22 defaultCacheTtl = 60 * 60 * 24 * 7;
23 maxCacheTtl = 60 * 60 * 24 * 7; 23 maxCacheTtl = 60 * 60 * 24 * 7;
24 pinentryFlavor = "curses"; 24 pinentryPackage = pkgs.pinentry-tty;
25 }; 25 };
26 }; 26 };
27 27