use rofi as confirm dialog
This commit is contained in:
parent
b0775d032a
commit
fb1f67a39a
5 changed files with 127 additions and 18 deletions
|
@ -29,7 +29,7 @@
|
|||
<action>
|
||||
<name>rm -rf</name>
|
||||
<icon>user-trash-full</icon>
|
||||
<command><% opt.commands.zenity %> --text "Delete these files?\n\n%F" && rm -rf %F</command>
|
||||
<command>[ "$(echo -e "Yes\nNo" | rofi -dmenu -theme ~/.local/share/rofi/applets/confirm.rasi -mesg $'Delete these Files?\n\n%F')" == Yes ] && rm -rf %F</command>
|
||||
<description>force delete stuff</description>
|
||||
<patterns>*</patterns>
|
||||
|
||||
|
|
89
.local/share/rofi/applets/confirm.rasi
Normal file
89
.local/share/rofi/applets/confirm.rasi
Normal file
|
@ -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);
|
||||
}
|
8
.local/share/rofi/common/colors.rasi
Normal file
8
.local/share/rofi/common/colors.rasi
Normal file
|
@ -0,0 +1,8 @@
|
|||
* {
|
||||
background: #1E1D2FFF;
|
||||
background-alt: #282839FF;
|
||||
foreground: #D9E0EEFF;
|
||||
selected: #7AA2F7FF;
|
||||
active: #ABE9B3FF;
|
||||
urgent: #F28FADFF;
|
||||
}
|
3
.local/share/rofi/common/fonts.rasi.cgt
Normal file
3
.local/share/rofi/common/fonts.rasi.cgt
Normal file
|
@ -0,0 +1,3 @@
|
|||
* {
|
||||
font: "<% opt.font %> 12";
|
||||
}
|
|
@ -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)))))
|
||||
|
|
Loading…
Reference in a new issue