Simplify & refactor desktop & terminal modules

This commit is contained in:
Henrik Lissner 2020-02-01 21:04:39 -05:00
parent 6b7150ecd8
commit 9d137dc744
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
11 changed files with 91 additions and 130 deletions

29
bin/scratch Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
SCRID=scratch
CMD='tmux new-session -A -s scratch -n scratch'
focused=$(xdotool getactivewindow)
scratch=$(xdotool search --onlyvisible --classname $SCRID)
if [[ -n $scratch ]]; then
if [[ $focused == $scratch ]]; then
xdotool windowkill $scratch
else
xdotool windowactivate $scratch
fi
elif command -v alacritty >/dev/null; then
alacritty --class $SCRID \
-d 90 26 \
-e $SHELL -c "$CMD"
elif command -v urxvt >/dev/null; then
urxvt -name $SCRID \
-geometry 100x26 \
-e $SHELL -c '${tmux}/bin/tmux new-session -A -s scratch -n scratch'
elif command -v xst >/dev/null; then
xst -t $SCRID -n $SCRID -c $SCRID \
-f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \
-g 100x26 \
-e $SHELL
else
>&2 echo "No shell to launch the scratch terminal with"
exit 1
fi

View file

@ -21,8 +21,7 @@ bspc rule -a Firefox split_ratio=0.32
bspc rule -a feh state=fullscreen bspc rule -a feh state=fullscreen
bspc rule -a 'Emacs:org*' state=floating bspc rule -a 'Emacs:org*' state=floating
bspc rule -a 'Emacs:scratch' state=floating bspc rule -a 'Emacs:scratch' state=floating
bspc rule -a URxvt:urxvt-scratch state=floating sticky=on center=on bspc rule -a '*:scratch' state=floating sticky=on center=on
bspc rule -a URxvt:urxvt-calc state=floating sticky=on center=on
# #

View file

@ -3,7 +3,7 @@ DIR="$(fd -L --type d . $HOME | rofi -dmenu -i -p files -columns 1 -theme theme/
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
cd "$DIR" cd "$DIR"
if [[ $1 == "-x" ]]; then if [[ $1 == "-x" ]]; then
st-scratch scratch
else else
xst xst
fi fi

View file

@ -21,10 +21,10 @@ super + {_,shift +}{1-9,0}
bspc {desktop -f,node -d} {1-9,10} bspc {desktop -f,node -d} {1-9,10}
super + Return super + Return
urxvt -e bash -c "tmux new || tmux attach" $TERMINAL -e bash -c "tmux new || tmux attach"
super + grave super + grave
urxvt-scratch scratch
super + shift + grave super + shift + grave
emacsclient -e '(open-scratch-frame)' emacsclient -e '(open-scratch-frame)'
@ -61,10 +61,10 @@ Print
scrcap scrcap
# screencast region to mp4 # screencast region to mp4
super + Print super + Print
scrrec -s ~/recordings/$(date +%F-%T).mp4 scrrec -s ~/shared/$(date +%F-%T).mp4
# screencast region to gif # screencast region to gif
super + ctrl + Print super + ctrl + Print
scrrec -s ~/recordings/$(date +%F-%T).gif scrrec -s ~/shared/$(date +%F-%T).gif
XF86MonBrightnessUp XF86MonBrightnessUp
light -A 5 light -A 5
@ -73,10 +73,8 @@ XF86MonBrightnessDown
XF86AudioMute XF86AudioMute
amixer -q set Master toggle amixer -q set Master toggle
XF86AudioLowerVolume XF86AudioLowerVolume
amixer -q set Master 10%- unmute amixer -q set Master 10%- unmute
XF86AudioRaiseVolume XF86AudioRaiseVolume
amixer -q set Master 10%+ unmute amixer -q set Master 10%+ unmute

View file

@ -5,8 +5,6 @@
my.zsh.rc = ''[ "$TERM" = xst-256color ] && export TERM=xterm-256color''; my.zsh.rc = ''[ "$TERM" = xst-256color ] && export TERM=xterm-256color'';
my.packages = with pkgs; [ my.packages = with pkgs; [
libqalculate # calculator cli w/ currency & unit conversion
xst # st + nice-to-have extensions xst # st + nice-to-have extensions
(makeDesktopItem { (makeDesktopItem {
name = "xst"; name = "xst";
@ -16,41 +14,5 @@
exec = "${xst}/bin/xst"; exec = "${xst}/bin/xst";
categories = "Development;System;Utility"; categories = "Development;System;Utility";
}) })
(writeScriptBin "st-scratch" ''
#!${stdenv.shell}
SCRID=st-scratch
focused=$(xdotool getactivewindow)
scratch=$(xdotool search --onlyvisible --classname $SCRID)
if [[ -n $scratch ]]; then
if [[ $focused == $scratch ]]; then
xdotool windowkill $scratch
else
xdotool windowactivate $scratch
fi
else
xst -t $SCRID -n $SCRID -c $SCRID \
-f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \
-g 100x26 \
-e $SHELL
fi
'')
(writeScriptBin "st-calc" ''
#!${stdenv.shell}
SCRID=st-calc
scratch=$(xdotool search --onlyvisible --classname $SCRID)
[ -n "$scratch" ] && xdotool windowkill $scratch
xst -t $SCRID -n $SCRID -c $SCRID \
-f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \
-g 80x12 \
-e $SHELL -c qalc
'')
(makeDesktopItem {
name = "st-calc";
desktopName = "Calculator";
icon = "calc";
exec = "st-calc";
categories = "Development";
})
]; ];
} }

View file

@ -2,41 +2,6 @@
{ {
my.packages = with pkgs; [ my.packages = with pkgs; [
libqalculate # calculator cli w/ currency & unit conversion
rxvt_unicode rxvt_unicode
(writeScriptBin "urxvt-scratch" ''
#!${stdenv.shell}
SCRID=urxvt-scratch
focused=$(xdotool getactivewindow)
scratch=$(xdotool search --onlyvisible --classname $SCRID)
if [[ -n $scratch ]]; then
if [[ $focused == $scratch ]]; then
xdotool windowkill $scratch
else
xdotool windowactivate $scratch
fi
else
urxvt -name $SCRID \
-geometry 100x26 \
-e $SHELL -c '${tmux}/bin/tmux new-session -A -s scratch -n scratch'
fi
'')
(writeScriptBin "urxvt-calc" ''
#!${stdenv.shell}
SCRID=urxvt-calc
scratch=$(xdotool search --onlyvisible --classname $SCRID)
[ -n "$scratch" ] && xdotool windowkill $scratch
urxvt -name $SCRID \
-geometry 80x20 \
-e $SHELL -c 'qalc'
'')
(makeDesktopItem {
name = "urxvt-calc";
desktopName = "Calculator";
icon = "calc";
exec = "urxvt-calc";
categories = "Development";
})
]; ];
} }

View file

@ -2,21 +2,11 @@
{ {
imports = [ imports = [
./. # common settings ./. # common settings
# My launcher
./apps/rofi.nix
# I often need a thumbnail browser to show off, peruse or organize photos,
# design work, or digital art.
./apps/thunar.nix
#
./apps/redshift.nix
#
./apps/urxvt.nix
]; ];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
lightdm lightdm
bspwm
dunst dunst
libnotify libnotify
(polybar.override { (polybar.override {
@ -26,24 +16,17 @@
]; ];
services = { services = {
xserver = {
enable = true;
windowManager.bspwm.enable = true;
desktopManager.xterm.enable = lib.mkDefault false;
displayManager.lightdm = {
enable = true;
greeters.mini = {
enable = true;
user = config.my.username;
};
};
};
compton.enable = true; compton.enable = true;
xserver = {
windowManager.default = "bspwm";
windowManager.bspwm.enable = true;
displayManager.lightdm.enable = true;
displayManager.lightdm.greeters.mini.enable = true;
};
}; };
# For polybar
my = { my = {
env.PATH = [ <config/bspwm/bin> ]; env.PATH = [ <bin/bspwm> ];
home.xdg.configFile = { home.xdg.configFile = {
"sxhkd".source = <config/sxhkd>; "sxhkd".source = <config/sxhkd>;
# link recursively so other modules can link files in their folders # link recursively so other modules can link files in their folders

View file

@ -1,17 +1,37 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
my = { imports = [
packages = with pkgs; [ ## Desktop apps
calibre # managing my ebooks ./apps/redshift.nix
evince # pdf reader ./apps/rofi.nix # My launcher
feh # image viewer ./apps/thunar.nix # I often need a thumbnail browser to show off, peruse
mpv # video player # or organize photos, design work, or digital art.
xclip
xdotool ## Terminal
]; # ./apps/alacritty.nix
# ./apps/st.nix
./apps/urxvt.nix
];
my.env.TERMINAL = "urxvt";
services.xserver = {
enable = true;
desktopManager.xterm.enable = lib.mkDefault false;
displayManager.lightdm.greeters.mini.user = config.my.username;
}; };
my.packages = with pkgs; [
calibre # managing my ebooks
evince # pdf reader
feh # image viewer
mpv # video player
xclip
xdotool
libqalculate # calculator cli w/ currency conversion
];
## Sound ## Sound
sound.enable = true; sound.enable = true;
hardware.pulseaudio.enable = true; hardware.pulseaudio.enable = true;

View file

@ -49,28 +49,33 @@
*.color241: #665c54 *.color241: #665c54
!! general
scratch.font: Fira Code:pixelsize=16
!! xst
st.opacity: 200
st.font: Fira Code:pixelsize=12
!! urxvt !! urxvt
URxvt*depth: 32 URxvt*depth: 32
URxvt*.background: [80]#101216 URxvt*.background: [80]#101216
! URxvt*.termName: xterm-256color ! URxvt*.termName: xterm-256color
URxvt*.borderless: 1
URxvt*.buffered: true URxvt*.buffered: true
URxvt*.cursorBlink: true URxvt*.cursorBlink: true
URxvt*.underlineColor: grey URxvt*.font: xft:Fira Code:pixelsize=12
URxvt*.borderless: 1
URxvt.iso14755: false
URxvt.iso14755_52: false
URxvt*.internalBorder: 10 URxvt*.internalBorder: 10
URxvt*.scrollBar: false URxvt*.letterSpace: 0
URxvt*.saveLines: 5000 URxvt*.lineSpace: 0
URxvt*.loginShell: false URxvt*.loginShell: false
URxvt.perl-ext-common: default,matcher
URxvt*.matcher.button: 1 URxvt*.matcher.button: 1
URxvt*.matcher.rend.0: Uline Bold fg5 URxvt*.matcher.rend.0: Uline Bold fg5
URxvt*.saveLines: 5000
URxvt*.scrollBar: false
URxvt*.underlineColor: grey
URxvt.clipboard.autocopy: true URxvt.clipboard.autocopy: true
URxvt.iso14755: false
! fonts URxvt.iso14755_52: false
URxvt*.lineSpace: 0 URxvt.perl-ext-common: default,matcher
URxvt*.letterSpace: 0
URxvt*.font: xft:Fira Code:pixelsize=12
urxvt-scratch.font: xft:Fira Code:pixelsize=16
urxvt-calc.font: xft:Fira Code:pixelsize=22