Skip to content

Commit

Permalink
fix: install screenshot dependencies
Browse files Browse the repository at this point in the history
Provided in the default Dom0 installation as it brings a much better
usability and small packages.

KDE ships with kdialog but without a screenshot utility.
Xfce ships with xfce4-screenshooter but without a dialog utility.
Scrot and Zenity are minimal tools that works on both DEs and are very
small packages.

Fixes: #22
  • Loading branch information
ben-grande committed Mar 15, 2024
1 parent 7c3d6ac commit 425748a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 23 deletions.
5 changes: 5 additions & 0 deletions salt/dom0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ If you need to develop in Dom0, install some goodies (bare bones):
sudo qubesctl state.apply dom0.install-dev
```

To forward ports from qubes to the external world:
```sh
sudo qubesctl state.apply dom0.port-forward
```

## Usage

You may have noticed the desktop experience in Dom0 has enhanced. You are
Expand Down
23 changes: 0 additions & 23 deletions salt/dom0/helpers.sls
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,4 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- makedirs: True

"{{ slsdotpath }}-screenshot-helper":
file.managed:
- name: /usr/local/bin/qvm-screenshot
- source: salt://{{ slsdotpath }}/files/bin/qvm-screenshot
- mode: "0755"
- user: root
- group: root
- makedirs: True

## TODO: KDE shortcuts
{% set gui_user = salt['cmd.shell']('groupmems -l -g qubes') -%}
{% set gui_user_id = salt['cmd.shell']('id -u ' ~ gui_user) -%}
"{{ slsdotpath }}-screenshot-keyboard-shortcuts-xfce":
cmd.run:
- name: |
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/{{ gui_user_id }}/bus"
export DBUS_SESSION_BUS_ADDRESS
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/Print" -n -s "qvm-screenshot --fullscreen"
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Alt>Print" -n -s "qvm-screenshot --region"
- runas: {{ gui_user }}
- require:
- file: "{{ slsdotpath }}-screenshot-helper"

{% endif -%}
1 change: 1 addition & 0 deletions salt/dom0/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ include:
- .kde
- .update-settings
- .xorg
- .screenshot

{% endif -%}
49 changes: 49 additions & 0 deletions salt/dom0/screenshot.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{% if grains['nodename'] == 'dom0' -%}

"{{ slsdotpath }}-screenshot-updated":
pkg.uptodate:
- refresh: True

"{{ slsdotpath }}-screenshot-installed":
pkg.installed:
- require:
- pkg: "{{ slsdotpath }}-screenshot-updated"
- refresh: True
- install_recommends: False
- skip_suggestions: True
- pkgs:
- zenity
- scrot

"{{ slsdotpath }}-screenshot-script":
file.managed:
- name: /usr/local/bin/qvm-screenshot
- source: salt://{{ slsdotpath }}/files/bin/qvm-screenshot
- mode: "0755"
- user: root
- group: root
- makedirs: True
- require:
- pkg: "{{ slsdotpath }}-screenshot-installed"

## TODO: KDE shortcuts
{% set gui_user = salt['cmd.shell']('groupmems -l -g qubes') -%}
{% set gui_user_id = salt['cmd.shell']('id -u ' ~ gui_user) -%}
"{{ slsdotpath }}-screenshot-keyboard-shortcuts-xfce":
cmd.run:
- name: |
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/{{ gui_user_id }}/bus"
export DBUS_SESSION_BUS_ADDRESS
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/Print" -n -s "qvm-screenshot --fullscreen"
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Alt>Print" -n -s "qvm-screenshot --region"
- runas: {{ gui_user }}
- require:
- file: "{{ slsdotpath }}-screenshot-script"

{% endif -%}
10 changes: 10 additions & 0 deletions salt/dom0/screenshot.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

base:
'dom0':
- match: nodegroup
- dom0.screenshot

0 comments on commit 425748a

Please sign in to comment.