2023-05-20 01:00:51 +01:00
|
|
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
|
|
|
;;
|
2024-02-18 16:08:02 +00:00
|
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
2023-05-20 01:00:51 +01:00
|
|
|
;;
|
|
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
|
|
|
;; URL: https://devheroes.codes/FG42/FG42
|
2024-04-05 21:04:36 +01:00
|
|
|
;; Version: 4.0.0
|
2023-05-20 01:00:51 +01:00
|
|
|
;;
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
2023-05-31 23:37:29 +01:00
|
|
|
(require 'seq)
|
|
|
|
|
|
|
|
(defvar fg42/monitors nil
|
|
|
|
"A plist containing monitor resolution profiles.
|
|
|
|
for example:
|
|
|
|
'(:hdmi-only
|
|
|
|
(\"--output HDMI-1 --primary\"
|
|
|
|
\"--output eDP-1 --off\")
|
|
|
|
:hdmi-main
|
|
|
|
(\"--output HDMI-1 --primary\"
|
|
|
|
\"--output eDP-1 --mode 1920x1080 --left-of HDMI-1\")
|
|
|
|
:edp-only
|
|
|
|
(\"--output eDP-1 --mode 1920x1080\"
|
|
|
|
\"--output HDMI-1 --off\"))")
|
|
|
|
|
2023-05-20 01:00:51 +01:00
|
|
|
|
|
|
|
(defun fg42/get-x11-selection-text ()
|
|
|
|
"Return the X11 selection paste text."
|
|
|
|
(interactive)
|
2023-05-31 23:37:29 +01:00
|
|
|
(gui-get-selection 'PRIMARY))
|
|
|
|
|
|
|
|
|
|
|
|
(defun monitor-profiles ()
|
|
|
|
"Parse the `fg42/monitors' profiles."
|
|
|
|
(mapcar
|
|
|
|
#'car
|
|
|
|
(seq-partition fg42/monitors 2)))
|
|
|
|
|
|
|
|
(defun monitor (mon)
|
|
|
|
"Switch to the given monitor resolution profile MON."
|
|
|
|
(interactive
|
|
|
|
(list (completing-read
|
|
|
|
"Monitor Profole: "
|
|
|
|
(monitor-profiles))))
|
|
|
|
|
|
|
|
(let ((cmd (mapconcat (lambda (x) (format "xrandr %s" x))
|
|
|
|
(plist-get fg42/monitors (intern (format "%s" mon)))
|
|
|
|
" && ")))
|
|
|
|
(message "Setting monitor profile: %s" cmd)
|
|
|
|
(async-shell-command cmd "*xrandr*")))
|
2023-05-20 01:00:51 +01:00
|
|
|
|
|
|
|
(provide 'fg42/x)
|
|
|
|
;;; x.el ends here
|