I'm in the midst of transitioning onto a few new tools. My previous workflow just used `nix-env` to install *some* packages. I didn't have a prescribed methodology for which packages I would install using `nix-env` and which ones I would install using `sudo apt-get install`. Sometimes if a package would be available in my aptitude repositories, I'd use that; other times when it wasn't available I'd use `nix-env`. One complication about being on gLinux intead of NixOS is that some packages (e.g. nixpkgs.terminator) is available via `nix-env -iA nixpkgs.terminator`, but the installation won't actually run on my gLinux. In these instances, I would install terminator from the aptitude repositories. Then @tazjin introduced me to his Emacs configuration that he builds using Nix. What appealed to me about his built Emacs is that it worked as expected on either a NixOS machine and on gLinux (and presumably on other non-NixOS machines as well). A setup towards which I'm working is to own one or a few NixOS machines whose configurations are entirely managed with Nix. On devices like my work machines, which cannot run NixOS, I can build as much of the software that I need using Nix and attempt to minimize the ad hoc configuration either with shell scripts, python, golang, or more Nix code... it's clear that I still don't have a clear idea of how that part will work. For now, I'm adopting nix, nix-env, lorri, direnv, and weening off of aptitude as much as I can. Things are a bit messy, but my general trend feels positive. Stay tuned for more updates.
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			EmacsLisp
		
	
	
	
	
	
| ;; Author: William Carroll <wpcarro@gmail.com>
 | |
| 
 | |
| ;;; Commentary:
 | |
| ;; scrot is a Linux utility for taking screenshots.
 | |
| 
 | |
| ;;; Code:
 | |
| 
 | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | |
| ;; Dependencies
 | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | |
| 
 | |
| (require 'f)
 | |
| (require 'string)
 | |
| (require 'ts)
 | |
| (require 'clipboard)
 | |
| (require 'kbd)
 | |
| 
 | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | |
| ;; Library
 | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | |
| 
 | |
| (defconst scrot/screenshot-directory "~/Downloads"
 | |
|   "The default directory for screenshot outputs.")
 | |
| 
 | |
| (defconst scrot/path-to-executable "/usr/bin/scrot"
 | |
|   "Path to the scrot executable.")
 | |
| 
 | |
| (defconst scrot/output-format "screenshot_%H:%M:%S_%Y-%m-%d.png"
 | |
|   "The format string for the output screenshot file.
 | |
| See scrot's man page for more information.")
 | |
| 
 | |
| (defun scrot/copy-image (path)
 | |
|   "Use xclip to copy the image at PATH to the clipboard.
 | |
| This currently only works for PNG files because that's what I'm outputting"
 | |
|   (call-process "xclip" nil nil nil
 | |
|                 "-selection" "clipboard" "-t" "image/png" path)
 | |
|   (message (string/format "[scrot.el] Image copied to clipboard!")))
 | |
| 
 | |
| (defmacro scrot/call (&rest args)
 | |
|   "Call scrot with ARGS."
 | |
|   `(call-process ,scrot/path-to-executable nil nil nil ,@args))
 | |
| 
 | |
| (defun scrot/fullscreen ()
 | |
|   "Screenshot the entire screen."
 | |
|   (interactive)
 | |
|   (let ((screenshot-path (f-join scrot/screenshot-directory
 | |
|                                  (ts-format scrot/output-format (ts-now)))))
 | |
|     (scrot/call screenshot-path)
 | |
|     (scrot/copy-image screenshot-path)))
 | |
| 
 | |
| (defun scrot/select ()
 | |
|   "Click-and-drag to screenshot a region.
 | |
| The output path is copied to the user's clipboard."
 | |
|   (interactive)
 | |
|   (let ((screenshot-path (f-join scrot/screenshot-directory
 | |
|                                  (ts-format scrot/output-format (ts-now)))))
 | |
|     (scrot/call "--select" screenshot-path)
 | |
|     (scrot/copy-image screenshot-path)))
 | |
| 
 | |
| (provide 'scrot)
 | |
| ;;; scrot.el ends here
 |