Skip to content

Commit

Permalink
feat(rofi: screenshot): use banner like menu
Browse files Browse the repository at this point in the history
  • Loading branch information
d4ilyrun committed Dec 16, 2023
1 parent b4fe6f6 commit 2f4cd31
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 18 deletions.
2 changes: 1 addition & 1 deletion applications/rofi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let

in
{
xdg.configFile = copyConfigs [ "config" "powermenu" ];
xdg.configFile = copyConfigs [ "config" "powermenu" "screenshot" ];

programs.rofi = {
enable = true;
Expand Down
147 changes: 147 additions & 0 deletions applications/rofi/screenshot.rasi
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@import "dotfiles"

/**
*
* Author : Aditya Shakya (adi1090x)
* Github : @adi1090x
*
* Rofi Theme File
* Rofi Version: 1.7.3
**/

/*****----- Configuration -----*****/
configuration {
show-icons: false;
}

/*****----- Main Window -----*****/
window {
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
width: 800px;
x-offset: 0px;
y-offset: 0px;
margin: 0px;
padding: 0px;
border: 2px solid;
border-radius: 30px;
border-color: @accent;
cursor: "default";
background-color: @background;
}

/*****----- Main Box -----*****/
mainbox {
enabled: true;
spacing: 15px;
margin: 0px;
padding: 30px;
background-color: transparent;
children: [ "inputbar", "message", "listview" ];
}

/*****----- Inputbar -----*****/
inputbar {
enabled: true;
spacing: 10px;
padding: 0px;
border: 0px;
border-radius: 100%;
border-color: @selected;
background-color: transparent;
text-color: @foreground;
children: [ "textbox-prompt-colon", "prompt"];
}

textbox-prompt-colon {
enabled: true;
expand: false;
str: "";
padding: 10px 13px;
border-radius: 100%;
background-color: @red;
text-color: @background;
}
prompt {
enabled: true;
padding: 10px;
border-radius: 100%;
background-color: @green;
text-color: @background;
}

/*****----- Message -----*****/
message {
enabled: true;
margin: 0px;
padding: 10px;
border: 0px solid;
border-radius: 100%;
border-color: @selected;
background-color: @background-alt;
text-color: @foreground;
}
textbox {
background-color: inherit;
text-color: inherit;
vertical-align: 0.5;
horizontal-align: 0.0;
}

/*****----- Listview -----*****/
listview {
enabled: true;
columns: 6;
lines: 1;
cycle: true;
scrollbar: false;
layout: vertical;

spacing: 15px;
background-color: transparent;
cursor: "default";
}

/*****----- Elements -----*****/
element {
enabled: true;
padding: 30px 10px;
border: 0px solid;
border-radius: 100%;
border-color: @selected;
background-color: transparent;
text-color: @foreground;
cursor: pointer;
}
element-text {
font: "feather 28";
background-color: transparent;
text-color: inherit;
cursor: inherit;
vertical-align: 0.5;
horizontal-align: 0.4;
}

element normal.normal,
element alternate.normal {
background-color: var(background-alt);
text-color: var(foreground);
}
element normal.urgent,
element alternate.urgent,
element selected.active {
background-color: var(red);
text-color: var(background);
}
element normal.active,
element alternate.active,
element selected.urgent {
background-color: var(green);
text-color: var(background);
}
element selected.normal {
background-color: var(accent);
text-color: var(background);
}
34 changes: 17 additions & 17 deletions applications/rofi/scripts/screenshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ function rofi_chose_name() {
}

function rofi_select_list() {
rofi -dmenu -i \
-theme-str 'window { width: 250; height: 0%; padding: 0; margin: 0; }' \
-theme-str 'mainbox { height: 100%; width: 100%; }' \
-theme-str 'listview { margin: 5px; }' \
-only-match \
rofi -dmenu \
-theme-str "window {width: 670px;}" \
-theme-str "listview {columns: 5; lines: 1;}" \
-theme-str 'textbox-prompt-colon {str: " ";}' \
-theme "screenshot" \
-markup-rows \
"$@"
}

Expand All @@ -30,19 +31,18 @@ function notify_user() {
}

function main() {
choices=`cat<<EOF
󰆏 Region  Clip
󰆏 Screen  Clip
 Region  File
 Screen  File
EOF`
select_clip='󰆞'
screen_clip=''
select_file='󰩭'
screen_file='󰍹'

choice=$(echo "$choices" | rofi_select_list)
choices=`echo -e "$select_clip\n$screen_clip\n$select_file\n$screen_file"`
choice=$(echo "$choices" | rofi_select_list -p "Screenshot" -mesg "DIR: ${screenshot_directory}")

screen_type=$(echo "$choice" | cut -d ' ' -f2)
save_type=$(echo "$choice" | cut -d ' ' -f4)

if [ "$save_type" == "File" ]; then
if [ "$choice" == "$select_file" ] || [ "$choice" == "$screen_file" ]; then
save_file=$(echo -e "$existing_screenshots" | rofi_chose_name)
save_file="${screenshot_directory}/${save_file}" # TODO: default extension ?
fi
Expand All @@ -57,19 +57,19 @@ EOF`
sleep 1

case "$choice" in
'󰆏 Region  Clip')
"$select_clip")
screenshot_region | xclip -selection clipboard -t image/png
notify_user "Selection copied to clipboard"
;;
' Region  File')
"$select_file")
screenshot_region "${save_file}"
notify_user "Selection saved to ${save_file}"
;;
'󰆏 Screen  Clip')
"$screen_clip")
maim | xclip -selection clipboard -t image/png
notify_user "Screenshot copied to clipboard"
;;
' Screen  File')
"$screen_file")
maim "${save_file}"
notify_user "Screenshot saved to ${save_file}"
;;
Expand Down

0 comments on commit 2f4cd31

Please sign in to comment.