Assorted shell and Python scripts
1#!/usr/bin/env sh 2# 3# A rofi powered menu to execute power related action. 4# Uses: systemctl poweroff, systemctl reboot, rofi, rofi-prompt, 5# xfce4-session-logout, xflock4 6# 7# This script is a modified version of 8# https://gitlab.com/vahnrr/rofi-menus#power-menu 9# 10# MIT License 11# 12# Copyright (c) 2023 Jeffrey Serio <hyperreal@fedoraproject.org> 13# Copyright (c) 2020 vahnrr 14# 15# Permission is hereby granted, free of charge, to any person obtaining a copy 16# of this software and associated documentation files (the "Software"), to deal 17# in the Software without restriction, including without limitation the rights 18# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19# copies of the Software, and to permit persons to whom the Software is 20# furnished to do so, subject to the following conditions: 21# 22# The above copyright notice and this permission notice shall be included in all 23# copies or substantial portions of the Software. 24# 25# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31# SOFTWARE. 32################################################################################ 33 34power_off=' Power off' 35reboot=' Reboot' 36lock=' Lock' 37suspend='鈴 Suspend' 38log_out=' Log out' 39 40chosen=$(printf '%s;%s;%s;%s;%s' "$power_off" "$reboot" "$lock" "$suspend" \ 41 "$log_out" \ 42 | rofi -theme-str 'window { width: 10em; height: 11em; }' \ 43 -dmenu -p "Session"\ 44 -sep ';' \ 45 -selected-row 2) 46 47case "$chosen" in 48 "$power_off") 49 rofiprompt --query 'Shutdown?' && sudo systemctl poweroff 50 ;; 51 52 "$reboot") 53 rofiprompt --query 'Reboot?' && sudo systemctl reboot 54 ;; 55 56 "$lock") 57 rofiprompt --query 'Lock screen?' && xflock4 58 ;; 59 60 "$log_out") 61 rofiprompt --query 'Logout?' && xfce4-session-logout 62 ;; 63 64 *) exit 1 ;; 65esac