From fb1f67a39a8f8614d92fb1598ed211c68b06d1fd Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sun, 17 Sep 2023 15:00:11 +0200 Subject: [PATCH] use rofi as confirm dialog --- .config/Thunar/uca.xml.cgt | 2 +- .local/share/rofi/applets/confirm.rasi | 89 +++++++++++++++++++++++++ .local/share/rofi/common/colors.rasi | 8 +++ .local/share/rofi/common/fonts.rasi.cgt | 3 + scripts/playvid.ros | 43 +++++++----- 5 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 .local/share/rofi/applets/confirm.rasi create mode 100644 .local/share/rofi/common/colors.rasi create mode 100644 .local/share/rofi/common/fonts.rasi.cgt diff --git a/.config/Thunar/uca.xml.cgt b/.config/Thunar/uca.xml.cgt index 2d0cc3c..47f628f 100644 --- a/.config/Thunar/uca.xml.cgt +++ b/.config/Thunar/uca.xml.cgt @@ -29,7 +29,7 @@ rm -rf user-trash-full - <% opt.commands.zenity %> --text "Delete these files?\n\n%F" && rm -rf %F + [ "$(echo -e "Yes\nNo" | rofi -dmenu -theme ~/.local/share/rofi/applets/confirm.rasi -mesg $'Delete these Files?\n\n%F')" == Yes ] && rm -rf %F force delete stuff * diff --git a/.local/share/rofi/applets/confirm.rasi b/.local/share/rofi/applets/confirm.rasi new file mode 100644 index 0000000..1cf4a52 --- /dev/null +++ b/.local/share/rofi/applets/confirm.rasi @@ -0,0 +1,89 @@ +/** + * Author : Aditya Shakya (adi1090x) and LordMZTE + * Github : @adi1090x + * + * Rofi Theme File + * Rofi Version: 1.7.3 + **/ + +/*****----- Configuration -----*****/ +configuration { + show-icons: false; +} + +/*****----- Global Properties -----*****/ +@import "../common/colors.rasi" +@import "../common/fonts.rasi" + +/*****----- Main Window -----*****/ +window { + location: center; + anchor: center; + fullscreen: false; + width: 500px; + cursor: "default"; + background-color: @background; +} + +/*****----- Main Box -----*****/ +mainbox { + spacing: 30px; + padding: 30px; + background-color: transparent; + children: [ "message", "listview" ]; +} + +/*****----- Message -----*****/ +message { + margin: 0px; + padding: 20px; + background-color: @background-alt; + text-color: @foreground; +} +textbox { + background-color: inherit; + text-color: inherit; + vertical-align: 0.5; + horizontal-align: 0.5; + placeholder-color: @foreground; + blink: true; + markup: true; +} + +/*****----- Listview -----*****/ +listview { + columns: 2; + lines: 1; + cycle: true; + dynamic: true; + scrollbar: false; + layout: vertical; + reverse: false; + fixed-height: true; + fixed-columns: true; + + spacing: 30px; + background-color: transparent; + text-color: @foreground; + cursor: "default"; +} + +/*****----- Elements -----*****/ +element { + padding: 60px 10px; + background-color: @background-alt; + text-color: @foreground; + cursor: pointer; +} +element-text { + font: "feather 48"; + background-color: transparent; + text-color: inherit; + cursor: inherit; + vertical-align: 0.5; + horizontal-align: 0.5; +} +element selected.normal { + background-color: var(selected); + text-color: var(background); +} diff --git a/.local/share/rofi/common/colors.rasi b/.local/share/rofi/common/colors.rasi new file mode 100644 index 0000000..be65366 --- /dev/null +++ b/.local/share/rofi/common/colors.rasi @@ -0,0 +1,8 @@ +* { + background: #1E1D2FFF; + background-alt: #282839FF; + foreground: #D9E0EEFF; + selected: #7AA2F7FF; + active: #ABE9B3FF; + urgent: #F28FADFF; +} diff --git a/.local/share/rofi/common/fonts.rasi.cgt b/.local/share/rofi/common/fonts.rasi.cgt new file mode 100644 index 0000000..f7a1f04 --- /dev/null +++ b/.local/share/rofi/common/fonts.rasi.cgt @@ -0,0 +1,3 @@ +* { + font: "<% opt.font %> 12"; +} diff --git a/scripts/playvid.ros b/scripts/playvid.ros index 5416c6e..c349934 100755 --- a/scripts/playvid.ros +++ b/scripts/playvid.ros @@ -5,26 +5,35 @@ exec ros -Q -- $0 "$@" |# (progn ;;init forms (ros:ensure-asdf) - #+quicklisp(ql:quickload '(uiop trivial-raw-io) :silent t)) + #+quicklisp(ql:quickload '(uiop) :silent t)) (defpackage :playvid (:use :cl)) (in-package :playvid) (defun main (&rest argv) - (let* ((vidfile (or (uiop:parse-native-namestring (car argv)) - (let ((dir (uiop:directory-files "."))) - (nth (random (length dir) (make-random-state t)) dir)))) - (basename (pathname-name vidfile))) - (format t "playing video: ~a~%" basename) - (uiop:run-program (list "mpv" (uiop:native-namestring vidfile)) - :input :interactive - :error-output :interactive - :output :interactive) - (format t "delete `~a`? [Y/n] " basename) - (force-output) - (let ((input (char-upcase (trivial-raw-io:read-char)))) - (format t "~a~%" input) - (when (char-equal #\Y input) - (format t "deleting file `~a`~%" basename) - (delete-file vidfile))))) + (let* ((vidfile (or (uiop:parse-native-namestring (car argv)) + (let ((dir (uiop:directory-files "."))) + (nth (random (length dir) (make-random-state t)) dir)))) + (basename (pathname-name vidfile))) + (format t "playing video: ~a~%" basename) + (uiop:run-program (list "mpv" (uiop:native-namestring vidfile)) + :input :interactive + :error-output :interactive + :output :interactive + :ignore-error-status t) + + (let ((confirm (uiop:run-program (list + "rofi" + "-dmenu" + "-theme" + (format nil "~a/.local/share/rofi/applets/confirm.rasi" + (user-homedir-pathname)) + "-mesg" + (format nil "delete `~a`?" basename)) + :input (lambda (s) (format s "No~CYes" #\newline)) + :ignore-error-status t + :output :string))) + (when (string-equal (format nil "Yes~C" #\newline) confirm) + (format t "deleting file `~a`~%" basename) + (delete-file vidfile)))))