├── .gitignore
├── .vscode
├── launch.json
└── tasks.json
├── LICENSE
├── Makefile
├── README.md
├── contrib
├── images
│ └── swayfx-way-shell.png
├── systemd
│ └── way-shell.service
└── toolbox
│ └── fedora
│ ├── Dockerfile
│ └── Makefile
├── data
├── dbus-interfaces
│ ├── com.canonical.dbusmenu.xml
│ ├── net.hadess.PowerProfiles.xml
│ ├── org.freedesktop.DBus.xml
│ ├── org.freedesktop.Notifications.xml
│ ├── org.freedesktop.login1.Manager.xml
│ ├── org.freedesktop.login1.Seat.xml
│ ├── org.freedesktop.login1.Session.xml
│ ├── org.freedesktop.login1.User.xml
│ ├── org.kde.StatusNotifierHost.xml
│ ├── org.kde.StatusNotifierItem.xml
│ ├── org.kde.StatusNotifierWatcher.xml
│ └── org.mpris.MediaPlayer2.xml
├── org.ldelossa.way-shell.gschema.xml
├── theme
│ ├── way-shell-dark.css
│ └── way-shell-light.css
├── wayland-protocols
│ └── staging
│ │ └── ext-idle-notify-v1.xml
└── wlr-protocols
│ └── unstable
│ ├── wlr-foreign-toplevel-management-unstable-v1.xml
│ ├── wlr-gamma-control-unstable-v1.xml
│ ├── wlr-input-inhibitor-unstable-v1.xml
│ └── wlr-output-management-unstable-v1.xml
├── gresources.xml
├── lib
└── cmd_tree
│ ├── Makefile
│ ├── cmd_tree.c
│ └── include
│ └── cmd_tree.h
├── src
├── activities
│ ├── activities.c
│ ├── activities.h
│ ├── activities_app_widget.c
│ └── activities_app_widget.h
├── app_switcher
│ ├── app_switcher.c
│ ├── app_switcher.h
│ ├── app_switcher_app_widget.c
│ └── app_switcher_app_widget.h
├── dialog_overlay
│ ├── dialog_overlay.c
│ └── dialog_overlay.h
├── main.c
├── osd
│ ├── osd.c
│ └── osd.h
├── output_switcher
│ ├── output_switcher.c
│ ├── output_switcher.h
│ ├── output_switcher_output_widget.c
│ └── output_switcher_output_widget.h
├── panel
│ ├── indicator_bar
│ │ ├── indicator_bar.c
│ │ ├── indicator_bar.h
│ │ ├── indicator_widget.c
│ │ └── indicator_widget.h
│ ├── message_tray
│ │ ├── calendar
│ │ │ ├── calendar.c
│ │ │ └── calendar.h
│ │ ├── message_tray.c
│ │ ├── message_tray.h
│ │ └── notifications
│ │ │ ├── notification_group.c
│ │ │ ├── notification_group.h
│ │ │ ├── notification_osd.c
│ │ │ ├── notification_osd.h
│ │ │ ├── notification_widget.c
│ │ │ ├── notification_widget.h
│ │ │ ├── notifications_list.c
│ │ │ └── notifications_list.h
│ ├── panel.c
│ ├── panel.h
│ ├── panel_clock.c
│ ├── panel_clock.h
│ ├── panel_mediator.c
│ ├── panel_mediator.h
│ ├── panel_status_bar
│ │ ├── panel_status_bar.c
│ │ ├── panel_status_bar.h
│ │ ├── panel_status_bar_airplane_mode_button.c
│ │ ├── panel_status_bar_airplane_mode_button.h
│ │ ├── panel_status_bar_idle_inhibitor_button.c
│ │ ├── panel_status_bar_idle_inhibitor_button.h
│ │ ├── panel_status_bar_network_button.c
│ │ ├── panel_status_bar_network_button.h
│ │ ├── panel_status_bar_nightlight_button.c
│ │ ├── panel_status_bar_nightlight_button.h
│ │ ├── panel_status_bar_power_button.c
│ │ ├── panel_status_bar_power_button.h
│ │ ├── panel_status_bar_sound_button.c
│ │ ├── panel_status_bar_sound_button.h
│ │ ├── panel_status_bar_vpn_button.c
│ │ └── panel_status_bar_vpn_button.h
│ ├── panel_workspaces_bar
│ │ ├── panel_workspaces_bar.c
│ │ └── panel_workspaces_bar.h
│ └── quick_settings
│ │ ├── quick_settings.c
│ │ ├── quick_settings.h
│ │ ├── quick_settings_grid
│ │ ├── quick_settings_grid.c
│ │ ├── quick_settings_grid.h
│ │ ├── quick_settings_grid_airplane_mode_button.c
│ │ ├── quick_settings_grid_airplane_mode_button.h
│ │ ├── quick_settings_grid_button.c
│ │ ├── quick_settings_grid_button.h
│ │ ├── quick_settings_grid_cluster.c
│ │ ├── quick_settings_grid_cluster.h
│ │ ├── quick_settings_grid_ethernet.c
│ │ ├── quick_settings_grid_ethernet.h
│ │ ├── quick_settings_grid_idle_inhibitor.c
│ │ ├── quick_settings_grid_idle_inhibitor.h
│ │ ├── quick_settings_grid_night_light
│ │ │ ├── quick_settings_grid_night_light.c
│ │ │ ├── quick_settings_grid_night_light.h
│ │ │ ├── quick_settings_grid_night_light_menu.c
│ │ │ └── quick_settings_grid_night_light_menu.h
│ │ ├── quick_settings_grid_oneshot_button.c
│ │ ├── quick_settings_grid_oneshot_button.h
│ │ ├── quick_settings_grid_power_profiles
│ │ │ ├── quick_settings_grid_power_profiles.c
│ │ │ ├── quick_settings_grid_power_profiles.h
│ │ │ ├── quick_settings_grid_power_profiles_menu.c
│ │ │ └── quick_settings_grid_power_profiles_menu.h
│ │ ├── quick_settings_grid_theme.c
│ │ ├── quick_settings_grid_theme.h
│ │ ├── quick_settings_grid_vpn
│ │ │ ├── quick_settings_grid_vpn.c
│ │ │ ├── quick_settings_grid_vpn.h
│ │ │ ├── quick_settings_grid_vpn_menu.c
│ │ │ └── quick_settings_grid_vpn_menu.h
│ │ ├── quick_settings_grid_wifi
│ │ │ ├── quick_settings_grid_wifi.c
│ │ │ ├── quick_settings_grid_wifi.h
│ │ │ ├── quick_settings_grid_wifi_menu.c
│ │ │ ├── quick_settings_grid_wifi_menu.h
│ │ │ ├── quick_settings_grid_wifi_menu_option.c
│ │ │ └── quick_settings_grid_wifi_menu_option.h
│ │ └── quick_settings_keyboard_brightness
│ │ │ ├── quick_settings_grid_keyboard_brightness.c
│ │ │ ├── quick_settings_grid_keyboard_brightness.h
│ │ │ ├── quick_settings_grid_keyboard_brightness_menu.c
│ │ │ └── quick_settings_grid_keyboard_brightness_menu.h
│ │ ├── quick_settings_header
│ │ ├── quick_settings_battery_button.c
│ │ ├── quick_settings_battery_button.h
│ │ ├── quick_settings_battery_menu.c
│ │ ├── quick_settings_battery_menu.h
│ │ ├── quick_settings_header.c
│ │ ├── quick_settings_header.h
│ │ ├── quick_settings_header_mixer
│ │ │ ├── quick_settings_header_mixer.c
│ │ │ ├── quick_settings_header_mixer.h
│ │ │ ├── quick_settings_header_mixer_menu_option.c
│ │ │ └── quick_settings_header_mixer_menu_option.h
│ │ ├── quick_settings_power_menu.c
│ │ └── quick_settings_power_menu.h
│ │ ├── quick_settings_menu_widget.c
│ │ ├── quick_settings_menu_widget.h
│ │ └── quick_settings_scales
│ │ ├── quick_settings_scales.c
│ │ └── quick_settings_scales.h
├── rename_switcher
│ ├── rename_switcher.c
│ └── rename_switcher.h
├── services
│ ├── brightness_service
│ │ ├── brightness_service.c
│ │ └── brightness_service.h
│ ├── clock_service.c
│ ├── clock_service.h
│ ├── dbus_dbus.c
│ ├── dbus_dbus.h
│ ├── dbus_service.c
│ ├── dbus_service.h
│ ├── ipc_service
│ │ ├── ipc_commands.h
│ │ ├── ipc_service.c
│ │ └── ipc_service.h
│ ├── logind_service
│ │ ├── logind_manager_dbus.c
│ │ ├── logind_manager_dbus.h
│ │ ├── logind_service.c
│ │ ├── logind_service.h
│ │ ├── logind_session_dbus.c
│ │ └── logind_session_dbus.h
│ ├── media_player_service
│ │ ├── media_player_dbus.c
│ │ ├── media_player_dbus.h
│ │ ├── media_player_service.c
│ │ └── media_player_service.h
│ ├── network_manager_service.c
│ ├── network_manager_service.h
│ ├── notifications_service
│ │ ├── notifications_dbus.c
│ │ ├── notifications_dbus.h
│ │ ├── notifications_service.c
│ │ └── notifications_service.h
│ ├── power_profiles_service
│ │ ├── power_profiles_dbus.c
│ │ ├── power_profiles_dbus.h
│ │ ├── power_profiles_service.c
│ │ └── power_profiles_service.h
│ ├── status_notifier_service
│ │ ├── dbusmenu_dbus.c
│ │ ├── dbusmenu_dbus.h
│ │ ├── libdbus_menu_consts.h
│ │ ├── libdbusmenu.c
│ │ ├── libdbusmenu.h
│ │ ├── status_notifier_host_dbus.c
│ │ ├── status_notifier_host_dbus.h
│ │ ├── status_notifier_item_dbus.c
│ │ ├── status_notifier_item_dbus.h
│ │ ├── status_notifier_service.c
│ │ ├── status_notifier_service.h
│ │ ├── status_notifier_watcher_dbus.c
│ │ └── status_notifier_watcher_dbus.h
│ ├── theme_service.c
│ ├── theme_service.h
│ ├── upower_service.c
│ ├── upower_service.h
│ ├── wayland
│ │ ├── core.c
│ │ ├── core.h
│ │ ├── foreign_toplevel_service
│ │ │ ├── foreign_toplevel.c
│ │ │ └── foreign_toplevel.h
│ │ ├── gamma_control_service
│ │ │ ├── colorramp.h
│ │ │ ├── gamma.c
│ │ │ └── gamma.h
│ │ ├── keyboard_shortcuts_inhibit_service
│ │ │ ├── ksi.c
│ │ │ └── ksi.h
│ │ ├── wl_output.c
│ │ ├── wl_output.h
│ │ ├── wl_seat.c
│ │ ├── wl_seat.h
│ │ ├── wlr-foreign-toplevel-management-unstable-v1.c
│ │ ├── wlr-foreign-toplevel-management-unstable-v1.h
│ │ ├── wlr-gamma-control-unstable-v1.c
│ │ └── wlr-gamma-control-unstable-v1.h
│ ├── window_manager_service
│ │ ├── sway
│ │ │ ├── ipc.h
│ │ │ ├── sway_client.c
│ │ │ ├── sway_client.h
│ │ │ ├── window_manager_service_sway.c
│ │ │ └── window_manager_service_sway.h
│ │ ├── window_manager_service.c
│ │ └── window_manager_service.h
│ ├── wireplumber_service.c
│ └── wireplumber_service.h
├── switcher
│ ├── switcher.c
│ └── switcher.h
└── workspace_switcher
│ ├── workspace_switcher.c
│ ├── workspace_switcher.h
│ ├── workspace_switcher_workspace_widget.c
│ └── workspace_switcher_workspace_widget.h
├── way-sh
├── Makefile
├── activities_cmd.c
├── app_switcher_cmd.c
├── bluelight_filter_cmd.c
├── brightness_cmd.c
├── commands.h
├── main.c
├── message_tray_cmd.c
├── output_switcher_cmd.c
├── rename_switcher_cmd.c
├── root.c
├── theme_cmd.c
├── volume_cmd.c
├── workspace_app_switcher_cmd.c
└── workspace_switcher_cmd.c
└── way-shell.spec
/.gitignore:
--------------------------------------------------------------------------------
1 | **.*o
2 | compile_commands.json
3 | way-shell
4 | .gdb_history
5 | way-sh/way-sh
6 | gresources.c
7 | gresources.h
8 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Remote Debug",
9 | "type": "lldb",
10 | "request": "launch",
11 | "program": "${workspaceFolder}/way-shell", // Local path.
12 | "initCommands": [
13 | "platform select remote-linux", // For example: 'remote-linux', 'remote-macosx', 'remote-android', etc.
14 | "platform connect connect://0.0.0.0:7777",
15 | "settings set target.inherit-env false", // See note below.
16 | ],
17 | "env": {
18 | "XDG_RUNTIME_DIR": "/run/user/1000",
19 | "DBUS_SYSTEM_BUS_ADDRESS": "unix:path=/var/run/dbus/system_bus_socket",
20 | "SWAYSOCK": "/run/user/1000/sway-ipc.1000.4132927.sock"
21 | }
22 | }
23 | ]
24 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/contrib/images/swayfx-way-shell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldelossa/way-shell/32de3fa857c4952c688f034330e26a177b39dfdc/contrib/images/swayfx-way-shell.png
--------------------------------------------------------------------------------
/contrib/systemd/way-shell.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Runs way-shell once sway session target is reached
3 |
4 | [Service]
5 | Type=Exec
6 | # This is required when Way-Shell runs under systemd.
7 | #
8 | # Way-Shell launches other apps and these apps join the same control group,
9 | # even if a forked (daemonized) launch is performed.
10 | #
11 | # This directive tells systemd to only kill the main process when Way-Shell is
12 | # restarted or crashes, avoiding the killing of any launched apps.
13 | KillMode=process
14 | ExecStart=/usr/bin/way-shell
15 |
16 | [Install]
17 | WantedBy=sway-session.target
18 |
--------------------------------------------------------------------------------
/contrib/toolbox/fedora/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM quay.io/toolbx-images/fedora-toolbox:40
2 |
3 | RUN sudo dnf install -y \
4 | libadwaita-devel \
5 | upower-devel \
6 | wireplumber-devel \
7 | json-glib-devel \
8 | NetworkManager-libnm-devel \
9 | pulseaudio-libs-devel \
10 | meson \
11 | cmake \
12 | gtk-doc
13 |
14 | # build and install gtk4-layer-shell v1.0.1
15 | RUN cd /tmp && \
16 | curl -LO https://github.com/wmww/gtk4-layer-shell/archive/refs/tags/v1.0.2.tar.gz && \
17 | tar -xvf v1.0.2.tar.gz && cd gtk4-layer-shell-1.0.2 && \
18 | meson setup --prefix=/usr -Dexamples=true -Ddocs=true -Dtests=true build && \
19 | ninja -C build/ && \
20 | ninja -C build/ install && \
21 | rm -rf /tmp/v1.0.2.tar.gz \
22 | rm -rf gtk4-layer-shell-1.0.2
23 |
24 | # clone and build way-shell and way-sh
25 | RUN mkdir /src && \
26 | cd /src && \
27 | git clone https://github.com/ldelossa/way-shell.git && \
28 | cd way-shell && \
29 | git submodule init && git submodule update && \
30 | make && \
31 | make gschema && \
32 | cp way-shell /usr/local/bin/ && \
33 | cp way-sh/way-sh /usr/local/bin && \
34 | rm -rf /src
35 |
36 | CMD ["/usr/local/bin/way-shell"]
37 |
--------------------------------------------------------------------------------
/contrib/toolbox/fedora/Makefile:
--------------------------------------------------------------------------------
1 | all: build create run
2 |
3 | .PHONY:
4 | build:
5 | podman build -t way-shell:latest .
6 |
7 | .PHONY:
8 | create:
9 | toolbox create --image way-shell:latest way-shell
10 |
11 | .PHONY:
12 | run:
13 | toolbox run --container way-shell way-shell
14 |
15 |
16 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/net.hadess.PowerProfiles.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.freedesktop.Notifications.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.freedesktop.login1.Seat.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.freedesktop.login1.User.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.kde.StatusNotifierHost.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.kde.StatusNotifierItem.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.kde.StatusNotifierWatcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/data/dbus-interfaces/org.mpris.MediaPlayer2.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/data/wlr-protocols/unstable/wlr-input-inhibitor-unstable-v1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Copyright © 2018 Drew DeVault
5 |
6 | Permission to use, copy, modify, distribute, and sell this
7 | software and its documentation for any purpose is hereby granted
8 | without fee, provided that the above copyright notice appear in
9 | all copies and that both that copyright notice and this permission
10 | notice appear in supporting documentation, and that the name of
11 | the copyright holders not be used in advertising or publicity
12 | pertaining to distribution of the software without specific,
13 | written prior permission. The copyright holders make no
14 | representations about the suitability of this software for any
15 | purpose. It is provided "as is" without express or implied
16 | warranty.
17 |
18 | THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
19 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 | FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
23 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25 | THIS SOFTWARE.
26 |
27 |
28 |
29 |
30 | Clients can use this interface to prevent input events from being sent to
31 | any surfaces but its own, which is useful for example in lock screen
32 | software. It is assumed that access to this interface will be locked down
33 | to whitelisted clients by the compositor.
34 |
35 | Note! This protocol is deprecated and not intended for production use.
36 | For screen lockers, use the ext-session-lock-v1 protocol.
37 |
38 |
39 |
40 |
41 | Activates the input inhibitor. As long as the inhibitor is active, the
42 | compositor will not send input events to other clients.
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | While this resource exists, input to clients other than the owner of the
55 | inhibitor resource will not receive input events. Any client which
56 | previously had focus will receive a leave event and will not be given
57 | focus again. The client that owns this resource will receive all input
58 | events normally. The compositor will also disable all of its own input
59 | processing (such as keyboard shortcuts) while the inhibitor is active.
60 |
61 | The compositor may continue to send input events to selected clients,
62 | such as an on-screen keyboard (via the input-method protocol).
63 |
64 |
65 |
66 |
67 | Destroy the inhibitor and allow other clients to receive input.
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/gresources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | data/theme/way-shell-dark.css
5 |
6 |
7 |
8 |
9 | data/theme/way-shell-light.css
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lib/cmd_tree/Makefile:
--------------------------------------------------------------------------------
1 | CFLAGS += -g3 -O0
2 |
3 | all: cmd_tree_test cmd_tree.o
4 |
5 | cmd_tree.o:
6 |
7 | cmd_tree_test: cmd_tree.o
8 |
9 | clean:
10 | rm -f cmd_tree_test *.o
11 |
--------------------------------------------------------------------------------
/lib/cmd_tree/cmd_tree.c:
--------------------------------------------------------------------------------
1 | #include "include/cmd_tree.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | int cmd_tree_node_add_sibling(cmd_tree_node_t *n, cmd_tree_node_t *sibling) {
9 | if (n == NULL || sibling == NULL) {
10 | return -1;
11 | }
12 | if (!n->sibling) {
13 | n->sibling = sibling;
14 | return 1;
15 | }
16 | n = n->sibling;
17 | for (;;) {
18 | if (n->sibling == NULL) break;
19 | n = n->sibling;
20 | }
21 | n->sibling = sibling;
22 | return 1;
23 | }
24 |
25 | int cmd_tree_node_add_child(cmd_tree_node_t *n, cmd_tree_node_t *child) {
26 | if (n == NULL || child == NULL) {
27 | return -1;
28 | }
29 | if (!n->child) {
30 | n->child = child;
31 | return 1;
32 | }
33 | return cmd_tree_node_add_sibling(n->child, child);
34 | }
35 |
36 | int cmd_tree_search_assign_args(cmd_tree_node_t *root, int i, int argc,
37 | char **argv) {
38 |
39 | root->argv = argv + i;
40 | root->argc = argc - i;
41 | return 1;
42 | }
43 |
44 | // recursively search for nodes which matches the latter most token in argv.
45 | // we enter here only when argc > 0.
46 | void cmd_tree_search_recur(cmd_tree_node_t *cur, int i, int argc, char *argv[],
47 | cmd_tree_node_t **node) {
48 | // out of argv bounds, backtrack.
49 | if (i == argc) return;
50 |
51 | char *token = argv[i];
52 |
53 | cmd_tree_node_t *child = cur->child;
54 |
55 | while (child) {
56 | if (strcmp(child->name, token) == 0) {
57 | *node = child;
58 | // assign all trailing arguments to the child node.
59 | cmd_tree_search_assign_args(child, i + 1, argc, argv);
60 | cmd_tree_search_recur(child, i + 1, argc, argv, node);
61 | break;
62 | }
63 | child = child->sibling;
64 | }
65 |
66 | return;
67 | }
68 |
69 | int cmd_tree_search(cmd_tree_node_t *root, int argc, char *argv[],
70 | cmd_tree_node_t **cmd_node) {
71 | if (!root) {
72 | return -1;
73 | }
74 |
75 | *cmd_node = root;
76 |
77 | // if there's no arguments just return root
78 | if (argc == 0) {
79 | root->argc = 0;
80 | return 1;
81 | }
82 |
83 | cmd_tree_search_recur(root, 0, argc, argv, cmd_node);
84 | return 1;
85 | }
86 |
--------------------------------------------------------------------------------
/lib/cmd_tree/include/cmd_tree.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef CMD_TREE_H
3 | #define CMD_TREE_H
4 | #include
5 |
6 | #define CMD_TREE_MAX_NAME 256
7 |
8 | /**
9 | * Function pointer which implements a node's command.
10 | * @param ctx A pointer to application specific context.
11 | * @param argc The count of trailing arguments to the command.
12 | * @param argv The trailing arguments to the command.
13 | */
14 | typedef int (*cmd_tree_node_exec)(void *ctx, uint8_t argc, char **argv);
15 |
16 | /**
17 | * A node in the cmd_tree.
18 | */
19 | typedef struct cmd_tree_node {
20 | // Pointer to the next sibling node
21 | struct cmd_tree_node *sibling;
22 | // Pointer to the first child node
23 | struct cmd_tree_node *child;
24 | // Function pointer to the node's command
25 | cmd_tree_node_exec exec;
26 | // Array of arguments for the command
27 | char **argv;
28 | // Number of arguments for the command
29 | uint8_t argc;
30 | // Name of the command
31 | char name[CMD_TREE_MAX_NAME];
32 | } cmd_tree_node_t;
33 |
34 | /**
35 | * Adds a child node to a given node in the cmd_tree.
36 | *
37 | * @param n The node to add a child to.
38 | * @param child The child node to add.
39 | *
40 | * @return 1 on success, -1 on failure.
41 | */
42 | int cmd_tree_node_add_child(cmd_tree_node_t *n, cmd_tree_node_t *child);
43 |
44 | /**
45 | * Searches for a command node in the cmd_tree starting from the given root
46 | * node.
47 | *
48 | * @param root The root node of the cmd_tree to search from.
49 | * @param argc The length of argv.
50 | * @param argv An array of string pointers of size @argc
51 | * @param cmd_node A pointer to a cmd_tree_node_t pointer that will be set to
52 | * the found command node.
53 | *
54 | * @return 1 if the command node was found and -1 if an error occurred.
55 | */
56 | int cmd_tree_search(cmd_tree_node_t *root, int argc, char *argv[],
57 | cmd_tree_node_t **cmd_node);
58 |
59 | #endif // CMD_TREE_H
60 |
--------------------------------------------------------------------------------
/src/activities/activities.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _Activities;
8 | #define ACTIVITIES_TYPE activities_get_type()
9 | G_DECLARE_FINAL_TYPE(Activities, activities, Activities, Activities, GObject);
10 |
11 | G_END_DECLS
12 |
13 | void activites_reinitialize(Activities *self);
14 |
15 | void activities_activate(AdwApplication *app, gpointer user_data);
16 |
17 | Activities *activities_get_global();
18 |
19 | void activities_show(Activities *self);
20 |
21 | void activities_hide(Activities *self);
22 |
23 | void activities_toggle(Activities *self);
24 |
25 |
--------------------------------------------------------------------------------
/src/activities/activities_app_widget.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _ActivitesAppWidget;
8 | #define ACTIVITIES_APP_WIDGET_TYPE activities_app_widget_get_type()
9 | G_DECLARE_FINAL_TYPE(ActivitiesAppWidget, activities_app_widget, Activities,
10 | AppWidget, GObject);
11 |
12 | G_END_DECLS
13 |
14 | void activities_app_widget_set_app_info(ActivitiesAppWidget *self,
15 | GAppInfo *app_info);
16 |
17 | GAppInfo *activities_app_widget_get_app_info(ActivitiesAppWidget *self);
18 |
19 | void activities_app_widget_simulate_click(ActivitiesAppWidget *self);
20 |
21 | GtkWidget *activities_app_widget(ActivitiesAppWidget *self);
22 |
23 | ActivitiesAppWidget *activities_app_widget_from_widget(GtkWidget *widget);
24 |
--------------------------------------------------------------------------------
/src/app_switcher/app_switcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "app_switcher_app_widget.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _AppSwitcher;
10 | #define APP_SWITCHER_TYPE app_switcher_get_type()
11 | G_DECLARE_FINAL_TYPE(AppSwitcher, app_switcher, App, Switcher, GObject);
12 |
13 | G_END_DECLS
14 |
15 | void app_switcher_activate(AdwApplication *app, gpointer user_data);
16 |
17 | AppSwitcher *app_switcher_get_global();
18 |
19 | void app_switcher_show(AppSwitcher *self);
20 |
21 | void app_switcher_hide(AppSwitcher *self);
22 |
23 | void app_switcher_toggle(AppSwitcher *self);
24 |
25 | void app_switcher_focus_by_app_widget(AppSwitcher *self,
26 | AppSwitcherAppWidget *widget);
27 |
28 | GtkWindow *app_switcher_get_window(AppSwitcher *self);
29 |
30 | void app_switcher_enter_preview(AppSwitcher *self);
31 |
32 | void app_switcher_exit_preview(AppSwitcher *self);
33 |
34 | void app_switcher_unfocus_widget_all(AppSwitcher *self);
35 |
--------------------------------------------------------------------------------
/src/app_switcher/app_switcher_app_widget.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "./../services/wayland/foreign_toplevel_service/foreign_toplevel.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _AppSwitcherAppWidget;
10 | #define APP_SWITCHER_APP_WIDGET_TYPE app_switcher_app_widget_get_type()
11 | G_DECLARE_FINAL_TYPE(AppSwitcherAppWidget, app_switcher_app_widget, AppSwitcher,
12 | AppWidget, GObject);
13 |
14 | G_END_DECLS
15 |
16 | GtkWidget *app_switcher_app_widget_get_widget(AppSwitcherAppWidget *self);
17 |
18 | void app_switcher_app_widget_add_toplevel(AppSwitcherAppWidget *self,
19 | WaylandWLRForeignTopLevel *toplevel);
20 |
21 | gboolean app_switcher_app_widget_remove_toplevel(
22 | AppSwitcherAppWidget *self, WaylandWLRForeignTopLevel *toplevel);
23 |
24 | gchar *app_switcher_app_widget_get_app_id(AppSwitcherAppWidget *self);
25 |
26 | void app_switcher_app_widget_activate(AppSwitcherAppWidget *self);
27 |
28 | void app_switcher_app_widget_set_focused(AppSwitcherAppWidget *self,
29 | gboolean select_previous);
30 |
31 | void app_switcher_app_widget_set_focused_next_instance(
32 | AppSwitcherAppWidget *self);
33 |
34 | void app_switcher_app_widget_set_focused_prev_instance(
35 | AppSwitcherAppWidget *self);
36 |
37 | void app_switcher_app_widget_unset_focus(AppSwitcherAppWidget *self);
38 |
39 | void app_switcher_app_widget_update_last_activated(
40 | AppSwitcherAppWidget *self, WaylandWLRForeignTopLevel *toplevel);
41 |
--------------------------------------------------------------------------------
/src/dialog_overlay/dialog_overlay.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | // Shows a full-output overlay with a dialog in the middle.
8 | // The user can either select "confirm" or "cancel".
9 | // When "confirm" is selected the GCallback provided to "dialog_overlay_present"
10 | // is called.
11 | struct _DialogOverlay;
12 | #define DIALOG_OVERLAY_TYPE dialog_overlay_get_type()
13 | G_DECLARE_FINAL_TYPE(DialogOverlay, dialog_overlay, Dialog, Overlay, GObject);
14 |
15 | G_END_DECLS
16 |
17 | void dialog_overlay_reinitialize(DialogOverlay *self);
18 |
19 | void dialog_overlay_activate(AdwApplication *app, gpointer user_data);
20 |
21 | DialogOverlay *dialog_overlay_get_global();
22 |
23 | void dialog_overlay_present(DialogOverlay *self, gchar *heading, gchar *body,
24 | GCallback cb);
25 |
--------------------------------------------------------------------------------
/src/osd/osd.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _OSD;
8 | #define OSD_TYPE osd_get_type()
9 | G_DECLARE_FINAL_TYPE(OSD, osd, OSD, OSD, GObject);
10 |
11 | G_END_DECLS
12 |
13 | void osd_reinitialize(OSD *self);
14 |
15 | void osd_activate(AdwApplication *app, gpointer user_data);
16 |
17 | OSD *osd_get_global();
18 |
19 | void osd_set_hidden(OSD *self);
20 |
--------------------------------------------------------------------------------
/src/output_switcher/output_switcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "output_switcher_output_widget.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _OutputSwitcher;
10 | #define OUTPUT_SWITCHER_TYPE output_switcher_get_type()
11 | G_DECLARE_FINAL_TYPE(OutputSwitcher, output_switcher, Output, Switcher,
12 | GObject);
13 |
14 | struct _OutputModel;
15 | #define OUTPUT_MODEL_TYPE output_model_get_type()
16 | G_DECLARE_FINAL_TYPE(OutputModel, output_model, Output, Model,
17 | GObject);
18 |
19 | G_END_DECLS
20 |
21 | void output_switcher_activate(AdwApplication *app, gpointer user_data);
22 |
23 | OutputSwitcher *output_switcher_get_global();
24 |
25 | void output_switcher_show(OutputSwitcher *self);
26 |
27 | void output_switcher_hide(OutputSwitcher *self);
28 |
29 | void output_switcher_toggle(OutputSwitcher *self);
30 |
--------------------------------------------------------------------------------
/src/output_switcher/output_switcher_output_widget.c:
--------------------------------------------------------------------------------
1 | #include "./output_switcher_output_widget.h"
2 |
3 | #include
4 |
5 | enum signals { signals_n };
6 |
7 | typedef struct _OutputSwitcherOutputWidget {
8 | GObject parent_instance;
9 | GtkBox *container;
10 | GtkLabel *label;
11 | } OutputSwitcherOutputWidget;
12 | static guint output_switcher_output_widget_signals[signals_n] = {0};
13 | G_DEFINE_TYPE(OutputSwitcherOutputWidget, output_switcher_output_widget,
14 | G_TYPE_OBJECT);
15 |
16 | // stub out dispose, finalize, class_init and init methods.
17 | static void output_switcher_output_widget_dispose(GObject *object) {
18 | G_OBJECT_CLASS(output_switcher_output_widget_parent_class)->dispose(object);
19 | }
20 |
21 | static void output_switcher_output_widget_finalize(GObject *object) {
22 | G_OBJECT_CLASS(output_switcher_output_widget_parent_class)
23 | ->finalize(object);
24 | }
25 |
26 | static void output_switcher_output_widget_class_init(
27 | OutputSwitcherOutputWidgetClass *class) {
28 | GObjectClass *object_class = G_OBJECT_CLASS(class);
29 | object_class->dispose = output_switcher_output_widget_dispose;
30 | object_class->finalize = output_switcher_output_widget_finalize;
31 | }
32 |
33 | static void output_switcher_output_widget_init_layout(
34 | OutputSwitcherOutputWidget *self) {
35 | self->container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
36 | gtk_widget_add_css_class(GTK_WIDGET(self->container), "switcher-entry");
37 |
38 | // add pointer to self on container
39 | g_object_set_data(G_OBJECT(self->container), "output-widget", self);
40 |
41 | self->label = GTK_LABEL(gtk_label_new(""));
42 | gtk_box_append(self->container, GTK_WIDGET(self->label));
43 | }
44 |
45 | static void output_switcher_output_widget_init(
46 | OutputSwitcherOutputWidget *self) {
47 | output_switcher_output_widget_init_layout(self);
48 | }
49 |
50 | void output_switcher_output_widget_set_output_name(
51 | OutputSwitcherOutputWidget *self, const gchar *name) {
52 | gtk_label_set_text(self->label, name);
53 | }
54 |
55 | gchar *output_switcher_output_widget_get_output_name(
56 | OutputSwitcherOutputWidget *self) {
57 | return g_strdup(gtk_label_get_text(self->label));
58 | }
59 |
60 | GtkWidget *output_switcher_output_widget_get_widget(
61 | OutputSwitcherOutputWidget *self) {
62 | return GTK_WIDGET(self->container);
63 | }
64 |
--------------------------------------------------------------------------------
/src/output_switcher/output_switcher_output_widget.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _OutputSwitcherOutputWidget;
9 | #define OUTPUT_SWITCHER_OUTPUT_WIDGET_TYPE \
10 | output_switcher_output_widget_get_type()
11 | G_DECLARE_FINAL_TYPE(OutputSwitcherOutputWidget, output_switcher_output_widget,
12 | OutputSwitcher, OutputWidget, GObject);
13 |
14 | G_END_DECLS
15 |
16 | void output_switcher_output_widget_set_output_name(
17 | OutputSwitcherOutputWidget *self, const gchar *name);
18 |
19 | char *output_switcher_output_widget_get_output_name(
20 | OutputSwitcherOutputWidget *self);
21 |
22 | GtkWidget *output_switcher_output_widget_get_widget(
23 | OutputSwitcherOutputWidget *self);
24 |
--------------------------------------------------------------------------------
/src/panel/indicator_bar/indicator_bar.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../panel.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _IndicatorBar;
10 | #define INDICATOR_BAR_TYPE indicator_bar_get_type()
11 | G_DECLARE_FINAL_TYPE(IndicatorBar, indicator_bar, INDICATOR, BAR, GObject);
12 |
13 | G_END_DECLS
14 |
15 | // Sets the owning panel
16 | void indicator_bar_set_panel(IndicatorBar *self, Panel *panel);
17 |
18 | // Sets the QS button's toggle state.
19 | // Effects the css applied to the button.
20 | void indicator_bar_set_toggled(IndicatorBar *self, gboolean toggled);
21 |
22 | GtkWidget *indicator_bar_get_widget(IndicatorBar *self);
23 |
--------------------------------------------------------------------------------
/src/panel/indicator_bar/indicator_widget.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../../services/status_notifier_service/status_notifier_service.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _IndicatorWidget;
10 | #define INDICATOR_WIDGET_TYPE indicator_widget_get_type()
11 | G_DECLARE_FINAL_TYPE(IndicatorWidget, indicator_widget, INDICATOR, WIDGET,
12 | GObject);
13 |
14 | G_END_DECLS
15 |
16 | void indicator_widget_set_sni(IndicatorWidget *self, StatusNotifierItem *sni);
17 |
18 | StatusNotifierItem *indicator_widget_get_sni(IndicatorWidget *self);
19 |
20 | GtkWidget *indicator_widget_get_widget(IndicatorWidget *self);
21 |
--------------------------------------------------------------------------------
/src/panel/message_tray/calendar/calendar.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _Calendar;
8 | #define CALENDAR_TYPE calendar_get_type()
9 | G_DECLARE_FINAL_TYPE(Calendar, calendar, MESSAGE_TRAY, CALENDAR, GObject);
10 |
11 | GtkWidget *calendar_get_widget(Calendar *self);
12 |
13 | G_END_DECLS
--------------------------------------------------------------------------------
/src/panel/message_tray/message_tray.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | // The top-of-screen Panel which exists on each monitor of the current
8 | // GdkSeat.
9 | struct _MessageTray;
10 | #define MESSAGE_TRAY_TYPE message_tray_get_type()
11 | G_DECLARE_FINAL_TYPE(MessageTray, message_tray, MESSAGE_TRAY, TRAY, GObject);
12 |
13 | G_END_DECLS
14 |
15 | // Intializes and activates the MessageTray subsystem.
16 | // After this returns the MessageTray window can be requested via a signal and
17 | // the global MessageTrayMediator can be retrieved.
18 | void message_tray_activate(AdwApplication *app, gpointer user_data);
19 |
20 | MessageTray *message_tray_get_global();
21 |
22 | // Opens the MessageTray on the current monitor.
23 | void message_tray_set_visible(MessageTray *self);
24 |
25 | // Closes the MessageTray.
26 | void message_tray_set_hidden(MessageTray *self);
27 |
28 | void message_tray_reinitialize(MessageTray *self);
29 |
30 | void message_tray_shrink(MessageTray *self);
31 |
32 | void message_tray_runtime_signals(MessageTray *self);
33 |
34 | void message_tray_toggle(MessageTray *self);
35 |
--------------------------------------------------------------------------------
/src/panel/message_tray/notifications/notification_group.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../../../services/notifications_service/notifications_service.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _NotificationGroup;
10 | #define NOTIFICATION_GROUP_TYPE notification_group_get_type()
11 | G_DECLARE_FINAL_TYPE(NotificationGroup, notification_group, NOTIFICATION, GROUP,
12 | GObject);
13 |
14 | G_END_DECLS
15 |
16 | GtkWidget *notification_group_get_widget(NotificationGroup *self);
17 |
18 | void notification_group_add_notification(NotificationGroup *self,
19 | Notification *n);
20 |
21 | gchar *notification_group_get_app_name(NotificationGroup *self);
22 |
23 | void notification_group_dismiss_all(NotificationGroup *self);
24 |
--------------------------------------------------------------------------------
/src/panel/message_tray/notifications/notification_osd.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "./notifications_list.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _NotificationsOSD;
10 | #define NOTIFICATIONS_OSD_TYPE notifications_osd_get_type()
11 | G_DECLARE_FINAL_TYPE(NotificationsOSD, notifications_osd, NOTIFICATIONS, OSD,
12 | GObject);
13 |
14 | G_END_DECLS
15 |
16 | void notification_osd_reinitialize(NotificationsOSD *self);
17 |
18 | void notification_osd_set_notification_list(NotificationsOSD *self,
19 | NotificationsList *list);
20 |
21 | void notification_osd_hide(NotificationsOSD *self);
22 |
--------------------------------------------------------------------------------
/src/panel/message_tray/notifications/notification_widget.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../../../services/media_player_service/media_player_service.h"
6 | #include "../../../services/notifications_service/notifications_service.h"
7 | #include "notification_osd.h"
8 |
9 | G_BEGIN_DECLS
10 |
11 | struct _NotificationWidget;
12 | #define NOTIFICATION_WIDGET_TYPE notification_widget_get_type()
13 | G_DECLARE_FINAL_TYPE(NotificationWidget, notification_widget, NOTIFICATION,
14 | WIDGET, GObject);
15 |
16 | G_END_DECLS
17 |
18 | NotificationWidget *notification_widget_from_notification(
19 | Notification *n, gboolean expand_on_enter);
20 |
21 | NotificationWidget *notification_widget_from_media_player(MediaPlayer *player);
22 |
23 | NotificationWidget *notification_widget_set_media_player(
24 | NotificationWidget *self, MediaPlayer *player);
25 |
26 | GtkWidget *notification_widget_get_widget(NotificationWidget *self);
27 |
28 | guint32 notification_widget_get_id(NotificationWidget *self);
29 |
30 | GtkLabel *notification_widget_get_summary(NotificationWidget *self);
31 |
32 | GtkLabel *notification_widget_get_body(NotificationWidget *self);
33 |
34 | void notification_widget_set_stack_effect(NotificationWidget *self,
35 | gboolean show);
36 |
37 | void notification_widget_dismiss_notification(NotificationWidget *self);
38 |
39 | gchar *notification_widget_get_media_player_name(NotificationWidget *self);
40 |
41 | // If the NotificationWidget is associated with an Notification on screen
42 | // display, this method will set a synthetic 'Hide' action button which
43 | // closes the OSD.
44 | void notification_widget_set_osd(NotificationWidget *self,
45 | NotificationsOSD *osd);
46 |
47 | NotificationsOSD *notification_widget_get_osd(NotificationWidget *self);
48 |
49 |
--------------------------------------------------------------------------------
/src/panel/message_tray/notifications/notifications_list.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../message_tray.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _NotificationsList;
10 | #define NOTIFICATIONS_LIST_TYPE notifications_list_get_type()
11 | G_DECLARE_FINAL_TYPE(NotificationsList, notifications_list, NOTIFICATIONS, LIST,
12 | GObject);
13 |
14 | G_END_DECLS
15 |
16 | GtkWidget *notifications_list_get_widget(NotificationsList *self);
17 |
18 | gboolean notifications_list_is_dnd(NotificationsList *self);
19 |
20 | void notifications_list_reinitialize(NotificationsList *self);
21 |
--------------------------------------------------------------------------------
/src/panel/panel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "panel_mediator.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | // The top-of-screen Panel which exists on each monitor of the current
10 | // GdkSeat.
11 | struct _Panel;
12 | #define PANEL_TYPE panel_get_type()
13 | G_DECLARE_FINAL_TYPE(Panel, panel, PANEL, PANEL, GObject);
14 |
15 | G_END_DECLS
16 |
17 | // Initializes and activates the Panel subsystem.
18 | // After this returns a set of Panels will exist for each monitor on
19 | //
20 | // TODO: Make this returns a pointer to the PanelMediator, such that it can be
21 | // passed to other initializing systems if desired.
22 | void panel_activate(AdwApplication *app, gpointer user_data);
23 |
24 | // Returns an instance to the global PanelMediator.
25 | // If `panel_activate` was not called prior to this it will return NULL, since
26 | // the panel subsystem is not initialized.
27 | //
28 | // If the caller will hold a referene to PanelMediator it should increase it's
29 | // ref count and decrement it once finished.
30 | PanelMediator *panel_get_global_mediator();
31 |
32 | // Called when the provided panel influenced the MessageTray to become visible.
33 | void panel_on_msg_tray_visible(Panel *panel);
34 |
35 | // Called when the provided panel influenced the MessageTray to be hidden.
36 | void panel_on_msg_tray_hidden(Panel *panel);
37 |
38 | // Called when the provided panel influenced the QuickSettings to become visible.
39 | void panel_on_qs_visible(Panel *panel);
40 |
41 | // Called when the provided panel influenced the QuickSettings to be hidden.
42 | void panel_on_qs_hidden(Panel *panel);
43 |
44 | // Returns the monitor the given Panel is on.
45 | GdkMonitor *panel_get_monitor(Panel *panel);
46 |
47 | // Attaches and displays a panel to the given monitor
48 | void panel_attach_to_monitor(Panel *panel, GdkMonitor *mon);
49 |
50 | Panel *panel_get_from_monitor(GdkMonitor *monitor);
51 |
52 | GHashTable *panel_get_all_panels();
53 |
--------------------------------------------------------------------------------
/src/panel/panel_clock.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "panel.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _PanelClock;
10 | #define PANEL_CLOCK_TYPE panel_clock_get_type()
11 | G_DECLARE_FINAL_TYPE(PanelClock, panel_clock, PANEL, CLOCK, GObject);
12 |
13 | G_END_DECLS
14 |
15 | GtkWidget *panel_clock_get_widget(PanelClock *self);
16 |
17 | GtkButton *panel_clock_get_button(PanelClock *self);
18 |
19 | void panel_clock_set_panel(PanelClock *self, Panel *panel);
20 |
21 | void panel_clock_set_toggled(PanelClock *self, gboolean toggled);
22 |
23 | gboolean panel_clock_get_toggled(PanelClock *self);
24 |
25 | void panel_clock_reinitialize(PanelClock *self);
26 |
--------------------------------------------------------------------------------
/src/panel/panel_mediator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | typedef struct _Panel Panel;
6 |
7 | G_BEGIN_DECLS
8 |
9 | // The mediator which aggregates and emits signals on behavior of Panels.
10 | // This is useful since multiple Panels can exist, one per GdkMonitor.
11 | // External components can connect to signals the PanelMediator emits rather
12 | // then each Panel.
13 | //
14 | // PanelMediator also acts as a high-level signal router for cross cutting
15 | // needs, such as closing the MessageTray component when the QuickSettings
16 | // component is opened.
17 | struct _PanelMediator;
18 | #define PANEL_MEDIATOR_TYPE panel_mediator_get_type()
19 | G_DECLARE_FINAL_TYPE(PanelMediator, panel_mediator, PANEL, MEDIATOR, GObject);
20 |
21 | G_END_DECLS
22 |
23 | // Emits the "notification_tray_toggle_request" signal for the give Panel.
24 | void panel_mediator_emit_msg_tray_toggle_request(PanelMediator *pm,
25 | Panel *panel);
26 |
27 | // Emits the "quick_settings_toggle_request" signal for the give Panel.
28 | void panel_mediator_emit_qs_toggle_request(PanelMediator *pm, Panel *panel);
29 |
30 | // Connects the PanelMediator to all other Mediator's signals required.
31 | void panel_mediator_connect(PanelMediator *mediator);
32 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../panel.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _PanelStatusBar;
10 | #define PANEL_STATUS_BAR_TYPE panel_status_bar_get_type()
11 | G_DECLARE_FINAL_TYPE(PanelStatusBar, panel_status_bar, PANEL, STATUS_BAR,
12 | GObject);
13 |
14 | G_END_DECLS
15 |
16 | // Sets the owning panel
17 | void panel_status_bar_set_panel(PanelStatusBar *self, Panel *panel);
18 |
19 | // Sets the QS button's toggle state.
20 | // Effects the css applied to the button.
21 | void panel_status_bar_set_toggled(PanelStatusBar *self, gboolean toggled);
22 |
23 | // Returns whether the QS button is toggled or not.
24 | gboolean quick_settings_get_toggled(PanelStatusBar *self);
25 |
26 | GtkBox *panel_status_bar_get_widget(PanelStatusBar *self);
27 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_airplane_mode_button.c:
--------------------------------------------------------------------------------
1 | #include "panel_status_bar_airplane_mode_button.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "../../services/network_manager_service.h"
7 | #include "glib.h"
8 |
9 | struct _PanelStatusBarAirplaneModeButton {
10 | GObject parent_instance;
11 | GtkImage *icon;
12 | };
13 | G_DEFINE_TYPE(PanelStatusBarAirplaneModeButton,
14 | panel_status_bar_airplane_mode_button, G_TYPE_OBJECT);
15 |
16 | static void handle_network_enabled_change(
17 | NetworkManagerService *nm, gboolean enabled,
18 | PanelStatusBarAirplaneModeButton *self) {
19 | // if we have an active airplane_mode connection show icon
20 | if (enabled)
21 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
22 | else {
23 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
24 | }
25 | }
26 |
27 | // stub out dispose, finalize, class_init, and init methods
28 | static void panel_status_bar_airplane_mode_button_dispose(GObject *gobject) {
29 | PanelStatusBarAirplaneModeButton *self =
30 | PANEL_STATUS_BAR_AIRPLANE_MODE_BUTTON(gobject);
31 |
32 | // kill signals
33 | NetworkManagerService *nm = network_manager_service_get_global();
34 | g_signal_handlers_disconnect_by_func(nm, handle_network_enabled_change,
35 | self);
36 |
37 | // Chain-up
38 | G_OBJECT_CLASS(panel_status_bar_airplane_mode_button_parent_class)
39 | ->dispose(gobject);
40 | };
41 |
42 | static void panel_status_bar_airplane_mode_button_finalize(GObject *gobject) {
43 | // Chain-up
44 | G_OBJECT_CLASS(panel_status_bar_airplane_mode_button_parent_class)
45 | ->finalize(gobject);
46 | };
47 |
48 | static void panel_status_bar_airplane_mode_button_class_init(
49 | PanelStatusBarAirplaneModeButtonClass *klass) {
50 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
51 | object_class->dispose = panel_status_bar_airplane_mode_button_dispose;
52 | object_class->finalize = panel_status_bar_airplane_mode_button_finalize;
53 | };
54 |
55 | static void panel_status_bar_airplane_mode_button_init_layout(
56 | PanelStatusBarAirplaneModeButton *self) {
57 | self->icon = GTK_IMAGE(
58 | gtk_image_new_from_icon_name("airplane-mode-symbolic"));
59 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
60 |
61 | // get initial airplane mode
62 | NetworkManagerService *nm = network_manager_service_get_global();
63 | gboolean enabled = network_manager_service_get_networking_enabled(nm);
64 |
65 | // if we have an active airplane_mode connection show icon
66 | if (!enabled) gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
67 |
68 | // connect to airplane_mode-activated, airplane_mode-deactivated events
69 | g_signal_connect(nm, "networking-enabled-changed",
70 | G_CALLBACK(handle_network_enabled_change), self);
71 | };
72 |
73 | static void panel_status_bar_airplane_mode_button_init(
74 | PanelStatusBarAirplaneModeButton *self) {
75 | panel_status_bar_airplane_mode_button_init_layout(self);
76 | }
77 |
78 | GtkWidget *panel_status_bar_airplane_mode_button_get_widget(
79 | PanelStatusBarAirplaneModeButton *self) {
80 | return GTK_WIDGET(self->icon);
81 | }
82 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_airplane_mode_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarAirplaneModeButton;
6 | #define PANEL_STATUS_BAR_AIRPLANE_MODE_BUTTON_TYPE \
7 | panel_status_bar_airplane_mode_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarAirplaneModeButton, panel_status_bar_airplane_mode_button,
9 | PANEL, STATUS_BAR_AIRPLANE_MODE_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_airplane_mode_button_get_widget(PanelStatusBarAirplaneModeButton *self);
14 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_idle_inhibitor_button.c:
--------------------------------------------------------------------------------
1 | #include "panel_status_bar_idle_inhibitor_button.h"
2 |
3 | #include
4 |
5 | #include "../../services/logind_service/logind_service.h"
6 |
7 | struct _PanelStatusBarIdleInhibitorButton {
8 | GObject parent_instance;
9 | GtkImage *icon;
10 | };
11 | G_DEFINE_TYPE(PanelStatusBarIdleInhibitorButton,
12 | panel_status_bar_idle_inhibitor_button, G_TYPE_OBJECT);
13 |
14 | static void on_idle_inhibitor_changed(LogindService *logind_service,
15 | gboolean inhibited,
16 | PanelStatusBarIdleInhibitorButton *self) {
17 | g_debug(
18 | "panel_status_bar_idle_inhibitor_button.c: "
19 | "on_idle_inhibitor_changed(): "
20 | "idle inhibitor changed: %d",
21 | inhibited);
22 |
23 | if (inhibited)
24 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
25 | else
26 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
27 | };
28 |
29 | // stub out dispose, finalize, class_init, and init methods
30 | static void panel_status_bar_idle_inhibitor_button_dispose(GObject *gobject) {
31 | PanelStatusBarIdleInhibitorButton *self =
32 | PANEL_STATUS_BAR_IDLE_INHIBITOR_BUTTON(gobject);
33 |
34 | // kill signals
35 | LogindService *logind = logind_service_get_global();
36 | g_signal_handlers_disconnect_by_func(logind, on_idle_inhibitor_changed,
37 | self);
38 |
39 | // Chain-up
40 | G_OBJECT_CLASS(panel_status_bar_idle_inhibitor_button_parent_class)
41 | ->dispose(gobject);
42 | };
43 |
44 | static void panel_status_bar_idle_inhibitor_button_finalize(GObject *gobject) {
45 | // Chain-up
46 | G_OBJECT_CLASS(panel_status_bar_idle_inhibitor_button_parent_class)
47 | ->finalize(gobject);
48 | };
49 |
50 | static void panel_status_bar_idle_inhibitor_button_class_init(
51 | PanelStatusBarIdleInhibitorButtonClass *klass) {
52 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
53 | object_class->dispose = panel_status_bar_idle_inhibitor_button_dispose;
54 | object_class->finalize = panel_status_bar_idle_inhibitor_button_finalize;
55 | };
56 |
57 | static void panel_status_bar_idle_inhibitor_button_init_layout(
58 | PanelStatusBarIdleInhibitorButton *self) {
59 | self->icon =
60 | GTK_IMAGE(gtk_image_new_from_icon_name("radio-mixed-symbolic"));
61 |
62 | LogindService *logind = logind_service_get_global();
63 | if (!logind) {
64 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
65 | return;
66 | }
67 |
68 | // get initial inhibited status
69 | gboolean inhibited =
70 | logind_service_get_idle_inhibit(logind_service_get_global());
71 |
72 | // if not inhibited set image visible false
73 | if (!inhibited) gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
74 |
75 | // connect idle inhibitor signal on logind
76 | g_signal_connect(logind, "idle-inhibitor-changed",
77 | G_CALLBACK(on_idle_inhibitor_changed), self);
78 | };
79 |
80 | static void panel_status_bar_idle_inhibitor_button_init(
81 | PanelStatusBarIdleInhibitorButton *self) {
82 | panel_status_bar_idle_inhibitor_button_init_layout(self);
83 | }
84 |
85 | GtkWidget *panel_status_bar_idle_inhibitor_button_get_widget(
86 | PanelStatusBarIdleInhibitorButton *self) {
87 | return GTK_WIDGET(self->icon);
88 | }
89 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_idle_inhibitor_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarIdleInhibitorButton;
6 | #define PANEL_STATUS_BAR_IDLE_INHIBITOR_BUTTON_TYPE \
7 | panel_status_bar_idle_inhibitor_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarIdleInhibitorButton, panel_status_bar_idle_inhibitor_button,
9 | PANEL, STATUS_BAR_IDLE_INHIBITOR_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_idle_inhibitor_button_get_widget(PanelStatusBarIdleInhibitorButton *self);
14 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_network_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarNetworkButton;
6 | #define PANEL_STATUS_BAR_NETWORK_BUTTON_TYPE \
7 | panel_status_bar_network_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarNetworkButton,
9 | panel_status_bar_network_button, PANEL,
10 | STATUS_BAR_NETWORK_BUTTON, GObject);
11 |
12 | G_END_DECLS
13 |
14 | GtkWidget *panel_status_bar_network_button_get_widget(
15 | PanelStatusBarNetworkButton *self);
16 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_nightlight_button.c:
--------------------------------------------------------------------------------
1 | #include "panel_status_bar_nightlight_button.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "../../services/wayland/gamma_control_service/gamma.h"
7 |
8 | struct _PanelStatusBarNightLightButton {
9 | GObject parent_instance;
10 | GtkImage *icon;
11 | };
12 | G_DEFINE_TYPE(PanelStatusBarNightLightButton,
13 | panel_status_bar_nightlight_button, G_TYPE_OBJECT);
14 |
15 | static void on_gamma_control_enabled(WaylandGammaControlService *w,
16 | PanelStatusBarNightLightButton *self) {
17 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
18 | }
19 |
20 | static void on_gamma_control_disabled(WaylandGammaControlService *w,
21 | PanelStatusBarNightLightButton *self) {
22 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
23 | }
24 |
25 | // stub out dispose, finalize, class_init, and init methods
26 | static void panel_status_bar_nightlight_button_dispose(GObject *gobject) {
27 | PanelStatusBarNightLightButton *self =
28 | PANEL_STATUS_BAR_NIGHTLIGHT_BUTTON(gobject);
29 |
30 | // kill signals
31 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
32 | g_signal_handlers_disconnect_by_func(w, on_gamma_control_enabled, self);
33 | g_signal_handlers_disconnect_by_func(w, on_gamma_control_disabled, self);
34 |
35 | // Chain-up
36 | G_OBJECT_CLASS(panel_status_bar_nightlight_button_parent_class)
37 | ->dispose(gobject);
38 | };
39 |
40 | static void panel_status_bar_nightlight_button_finalize(GObject *gobject) {
41 | // Chain-up
42 | G_OBJECT_CLASS(panel_status_bar_nightlight_button_parent_class)
43 | ->finalize(gobject);
44 | };
45 |
46 | static void panel_status_bar_nightlight_button_class_init(
47 | PanelStatusBarNightLightButtonClass *klass) {
48 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
49 | object_class->dispose = panel_status_bar_nightlight_button_dispose;
50 | object_class->finalize = panel_status_bar_nightlight_button_finalize;
51 | };
52 |
53 | static void panel_status_bar_nightlight_button_init_layout(
54 | PanelStatusBarNightLightButton *self) {
55 | self->icon =
56 | GTK_IMAGE(gtk_image_new_from_icon_name("night-light-symbolic"));
57 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
58 |
59 | // get initial active nightlights
60 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
61 | if (wayland_gamma_control_service_enabled(w))
62 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
63 |
64 | // if we have an active nightlight connection show icon
65 | g_signal_connect(w, "gamma-control-enabled",
66 | G_CALLBACK(on_gamma_control_enabled), self);
67 | g_signal_connect(w, "gamma-control-disabled",
68 | G_CALLBACK(on_gamma_control_disabled), self);
69 | };
70 |
71 | static void panel_status_bar_nightlight_button_init(
72 | PanelStatusBarNightLightButton *self) {
73 | panel_status_bar_nightlight_button_init_layout(self);
74 | }
75 |
76 | GtkWidget *panel_status_bar_nightlight_button_get_widget(
77 | PanelStatusBarNightLightButton *self) {
78 | return GTK_WIDGET(self->icon);
79 | }
80 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_nightlight_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarNightLightButton;
6 | #define PANEL_STATUS_BAR_NIGHTLIGHT_BUTTON_TYPE \
7 | panel_status_bar_nightlight_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarNightLightButton, panel_status_bar_nightlight_button,
9 | PANEL, STATUS_BAR_NIGHTLIGHT_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_nightlight_button_get_widget(PanelStatusBarNightLightButton *self);
14 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_power_button.c:
--------------------------------------------------------------------------------
1 | #include "panel_status_bar_power_button.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "../../services/upower_service.h"
7 |
8 | struct _PanelStatusBarPowerButton {
9 | GObject parent_instance;
10 | UpDevice *power_dev;
11 | GtkImage *icon;
12 | int signals[2];
13 | };
14 | G_DEFINE_TYPE(PanelStatusBarPowerButton, panel_status_bar_power_button,
15 | G_TYPE_OBJECT);
16 |
17 | static void on_battery_icon_change(GObject *object, GParamSpec *pspec,
18 | PanelStatusBarPowerButton *self) {
19 | char *icon_name = NULL;
20 |
21 | g_debug("panel_status_bar_power_button.c:on_battery_icon_change() called.");
22 |
23 | icon_name = upower_device_map_icon_name(UP_DEVICE(object));
24 |
25 | g_debug("quick_settings_button.c:on_battery_icon_change() icon_name: %s",
26 | icon_name);
27 |
28 | // update icon
29 | gtk_image_set_from_icon_name(self->icon, icon_name);
30 | }
31 |
32 | // stub out dispose, finalize, class_init, and init methods
33 | static void panel_status_bar_power_button_dispose(GObject *gobject) {
34 | PanelStatusBarPowerButton *self = PANEL_STATUS_BAR_POWER_BUTTON(gobject);
35 |
36 | // disconnect from signals
37 | g_signal_handler_disconnect(self->power_dev, self->signals[0]);
38 | g_signal_handler_disconnect(self->power_dev, self->signals[1]);
39 |
40 | // unref power device
41 | g_object_unref(self->power_dev);
42 |
43 | // Chain-up
44 | G_OBJECT_CLASS(panel_status_bar_power_button_parent_class)
45 | ->dispose(gobject);
46 | };
47 |
48 | static void panel_status_bar_power_button_finalize(GObject *gobject) {
49 | // Chain-up
50 | G_OBJECT_CLASS(panel_status_bar_power_button_parent_class)
51 | ->finalize(gobject);
52 | };
53 |
54 | static void panel_status_bar_power_button_class_init(
55 | PanelStatusBarPowerButtonClass *klass) {
56 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
57 | object_class->dispose = panel_status_bar_power_button_dispose;
58 | object_class->finalize = panel_status_bar_power_button_finalize;
59 | };
60 |
61 | static void panel_status_bar_power_button_init_layout(
62 | PanelStatusBarPowerButton *self) {
63 | gchar *name = NULL;
64 |
65 | // get power device
66 | UPowerService *upower = upower_service_get_global();
67 |
68 | self->power_dev = upower_service_get_primary_device(upower);
69 | g_object_ref(self->power_dev);
70 |
71 | name = upower_device_map_icon_name(self->power_dev);
72 |
73 | // create icon
74 | self->icon = GTK_IMAGE(gtk_image_new_from_icon_name(name));
75 |
76 | self->signals[0] =
77 | g_signal_connect(self->power_dev, "notify::percentage",
78 | G_CALLBACK(on_battery_icon_change), self);
79 | self->signals[1] =
80 | g_signal_connect(self->power_dev, "notify::state",
81 | G_CALLBACK(on_battery_icon_change), self);
82 |
83 | };
84 |
85 | static void panel_status_bar_power_button_init(
86 | PanelStatusBarPowerButton *self) {
87 | panel_status_bar_power_button_init_layout(self);
88 | }
89 |
90 | GtkWidget *panel_status_bar_power_button_get_widget(
91 | PanelStatusBarPowerButton *self) {
92 | return GTK_WIDGET(self->icon);
93 | }
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_power_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarPowerButton;
6 | #define PANEL_STATUS_BAR_POWER_BUTTON_TYPE \
7 | panel_status_bar_power_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarPowerButton, panel_status_bar_power_button,
9 | PANEL, STATUS_BAR_POWER_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_power_button_get_widget(PanelStatusBarPowerButton *self);
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_sound_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarSoundButton;
6 | #define PANEL_STATUS_BAR_SOUND_BUTTON_TYPE \
7 | panel_status_bar_sound_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarSoundButton, panel_status_bar_sound_button,
9 | PANEL, STATUS_BAR_SOUND_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_sound_button_get_widget(
14 | PanelStatusBarSoundButton *self);
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_vpn_button.c:
--------------------------------------------------------------------------------
1 | #include "panel_status_bar_vpn_button.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "../../services/network_manager_service.h"
7 | #include "glib.h"
8 |
9 | struct _PanelStatusBarVPNButton {
10 | GObject parent_instance;
11 | GtkImage *icon;
12 | };
13 | G_DEFINE_TYPE(PanelStatusBarVPNButton, panel_status_bar_vpn_button,
14 | G_TYPE_OBJECT);
15 |
16 | static void handle_vpn_change(NetworkManagerService *nm,
17 | NMActiveConnection *vpn_conn,
18 | PanelStatusBarVPNButton *self) {
19 |
20 | GHashTable *active_conns =
21 | network_manager_service_get_active_vpn_connections(nm);
22 | // if we have an active vpn connection show icon
23 | if (active_conns && g_list_length(g_hash_table_get_keys(active_conns)) > 0)
24 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
25 | else {
26 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
27 | }
28 | }
29 |
30 | // stub out dispose, finalize, class_init, and init methods
31 | static void panel_status_bar_vpn_button_dispose(GObject *gobject) {
32 | PanelStatusBarVPNButton *self = PANEL_STATUS_BAR_VPN_BUTTON(gobject);
33 |
34 | // kill signals
35 | NetworkManagerService *nm = network_manager_service_get_global();
36 | g_signal_handlers_disconnect_by_func(nm, handle_vpn_change, self);
37 |
38 | // Chain-up
39 | G_OBJECT_CLASS(panel_status_bar_vpn_button_parent_class)->dispose(gobject);
40 | };
41 |
42 | static void panel_status_bar_vpn_button_finalize(GObject *gobject) {
43 | // Chain-up
44 | G_OBJECT_CLASS(panel_status_bar_vpn_button_parent_class)->finalize(gobject);
45 | };
46 |
47 | static void panel_status_bar_vpn_button_class_init(
48 | PanelStatusBarVPNButtonClass *klass) {
49 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
50 | object_class->dispose = panel_status_bar_vpn_button_dispose;
51 | object_class->finalize = panel_status_bar_vpn_button_finalize;
52 | };
53 |
54 | static void panel_status_bar_vpn_button_init_layout(
55 | PanelStatusBarVPNButton *self) {
56 | self->icon =
57 | GTK_IMAGE(gtk_image_new_from_icon_name("network-vpn-symbolic"));
58 | gtk_widget_set_visible(GTK_WIDGET(self->icon), false);
59 |
60 | // get initial active vpns
61 | NetworkManagerService *nm = network_manager_service_get_global();
62 | GHashTable *active_conns =
63 | network_manager_service_get_active_vpn_connections(nm);
64 |
65 | // if we have an active vpn connection show icon
66 | if (active_conns && g_list_length(g_hash_table_get_keys(active_conns)) > 0)
67 | gtk_widget_set_visible(GTK_WIDGET(self->icon), true);
68 |
69 | // connect to vpn-activated, vpn-deactivated events
70 | g_signal_connect(nm, "vpn-activated", G_CALLBACK(handle_vpn_change), self);
71 | g_signal_connect(nm, "vpn-deactivated", G_CALLBACK(handle_vpn_change),
72 | self);
73 | };
74 |
75 | static void panel_status_bar_vpn_button_init(PanelStatusBarVPNButton *self) {
76 | panel_status_bar_vpn_button_init_layout(self);
77 | }
78 |
79 | GtkWidget *panel_status_bar_vpn_button_get_widget(
80 | PanelStatusBarVPNButton *self) {
81 | return GTK_WIDGET(self->icon);
82 | }
83 |
--------------------------------------------------------------------------------
/src/panel/panel_status_bar/panel_status_bar_vpn_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PanelStatusBarVPNButton;
6 | #define PANEL_STATUS_BAR_VPN_BUTTON_TYPE \
7 | panel_status_bar_vpn_button_get_type()
8 | G_DECLARE_FINAL_TYPE(PanelStatusBarVPNButton, panel_status_bar_vpn_button,
9 | PANEL, STATUS_BAR_VPN_BUTTON, GObject);
10 |
11 | G_END_DECLS
12 |
13 | GtkWidget *panel_status_bar_vpn_button_get_widget(PanelStatusBarVPNButton *self);
14 |
--------------------------------------------------------------------------------
/src/panel/panel_workspaces_bar/panel_workspaces_bar.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _PanelWorkspacesBar;
8 | #define PANEL_WORKSPACES_BAR_TYPE panel_workspaces_bar_get_type()
9 | G_DECLARE_FINAL_TYPE(PanelWorkspacesBar, panel_workspaces_bar, PANEL,
10 | WORKSPACES_BAR, GObject);
11 |
12 | G_END_DECLS
13 |
14 | typedef struct _Panel Panel;
15 |
16 | GtkWidget *panel_workspaces_bar_get_widget(PanelWorkspacesBar *self);
17 |
18 | void panel_workspaces_bar_set_panel(PanelWorkspacesBar *self, Panel *panel);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettings;
8 | #define QUICK_SETTINGS_TYPE quick_settings_get_type()
9 | G_DECLARE_FINAL_TYPE(QuickSettings, quick_settings, QS, QUICK_SETTINGS,
10 | GObject);
11 |
12 | G_END_DECLS
13 |
14 | // Intializes and activates the QuickSettings subsystem.
15 | // After this returns the QuickSettings window can be requested via a signal and
16 | void quick_settings_activate(AdwApplication *app, gpointer user_data);
17 |
18 | // Called to reinitialize the widget without allocating a new one.
19 | void quick_settings_reinitialize(QuickSettings *self);
20 |
21 | // Opens the QuickSettings relative to the given Panel.
22 | void quick_settings_set_visible(QuickSettings *qs);
23 |
24 | // Closes the QuickSettings relative to the given Panel.
25 | // If already hidden this results in a no-op.
26 | void quick_settings_set_hidden(QuickSettings *qs);
27 |
28 | // Toggles the QuickSettings window open or closed, determined by whether the
29 | // widget is visible or hidden under the give Panel.
30 | void quick_settings_toggle(QuickSettings *qs);
31 |
32 | // Shrink the QuickSettings UI to its original size, if possible.
33 | void quick_settings_shrink(QuickSettings *qs);
34 |
35 | void quick_settings_set_focused(QuickSettings *qs, gboolean focus);
36 |
37 | gboolean quick_settings_is_visible(QuickSettings *qs);
38 |
39 | QuickSettings *quick_settings_get_global();
40 |
41 | void quick_settings_toggle(QuickSettings *qs);
42 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _QuickSettingsGrid;
6 | #define QUICK_SETTINGS_GRID_TYPE quick_settings_grid_get_type()
7 | G_DECLARE_FINAL_TYPE(QuickSettingsGrid, quick_settings_grid, QUICK_SETTINGS,
8 | GRID, GObject);
9 |
10 | G_END_DECLS
11 |
12 | void quick_settings_grid_reinitialize(QuickSettingsGrid *grid);
13 |
14 | GtkWidget *quick_settings_grid_get_widget(QuickSettingsGrid *grid);
15 |
16 | void quick_settings_grid_add_setting(QuickSettingsGrid *grid, GtkWidget *w,
17 | GtkWidget *reveal);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_airplane_mode_button.c:
--------------------------------------------------------------------------------
1 | #include "./quick_settings_grid_airplane_mode_button.h"
2 |
3 | #include
4 |
5 | #include "../../../services/network_manager_service.h"
6 | #include "./quick_settings_grid_button.h"
7 |
8 | static void on_toggle_button_clicked(
9 | GtkButton *button, QuickSettingsGridAirplaneModeButton *self) {
10 | NetworkManagerService *nm = network_manager_service_get_global();
11 | gboolean enabled = network_manager_service_get_networking_enabled(nm);
12 |
13 | if (enabled)
14 | network_manager_service_networking_enable(nm, false);
15 | else
16 | network_manager_service_networking_enable(nm, true);
17 | }
18 |
19 | static void on_networking_enabled_changed(
20 | NetworkManagerService *nm, gboolean enabled,
21 | QuickSettingsGridAirplaneModeButton *self) {
22 | g_debug(
23 | "quick_settings_grid_airplane_mode_button.c: "
24 | "on_networking_enabled_changed(): "
25 | "networking enabled changed: %d",
26 | enabled);
27 |
28 | if (enabled)
29 | quick_settings_grid_button_set_toggled(&self->button, false);
30 | else
31 | quick_settings_grid_button_set_toggled(&self->button, true);
32 | }
33 |
34 | QuickSettingsGridAirplaneModeButton *
35 | quick_settings_grid_airplane_mode_button_init() {
36 | QuickSettingsGridAirplaneModeButton *self =
37 | g_malloc0(sizeof(QuickSettingsGridAirplaneModeButton));
38 |
39 | quick_settings_grid_button_init(
40 | &self->button, QUICK_SETTINGS_BUTTON_AIRPLANE_MODE, "Airplane Mode",
41 | NULL, "airplane-mode-symbolic", NULL, NULL);
42 |
43 | g_signal_connect(self->button.toggle, "clicked",
44 | G_CALLBACK(on_toggle_button_clicked), self);
45 |
46 | NetworkManagerService *nm = network_manager_service_get_global();
47 | gboolean enabled = network_manager_service_get_networking_enabled(nm);
48 |
49 | on_networking_enabled_changed(nm, enabled, self);
50 |
51 | // listen for networking mode changes
52 | g_signal_connect(nm, "networking-enabled-changed",
53 | G_CALLBACK(on_networking_enabled_changed), self);
54 |
55 | return self;
56 | }
57 |
58 | void quick_settings_grid_airplane_mode_button_free(
59 | QuickSettingsGridAirplaneModeButton *self) {
60 | // unref button's container
61 | g_object_unref(self->button.container);
62 |
63 | // kill signals
64 | NetworkManagerService *nm = network_manager_service_get_global();
65 | g_signal_handlers_disconnect_by_func(nm, on_networking_enabled_changed,
66 | self);
67 |
68 | // free ourselves
69 | g_free(self);
70 | }
71 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_airplane_mode_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "quick_settings_grid_button.h"
4 |
5 | #define QUICK_SETTINGS_AIRPLANE_MODE_TYPE "airplane_mode"
6 |
7 | typedef struct _QuickSettingsGridAirplaneModeMenu
8 | QuickSettingsGridAirplaneModeMenu;
9 |
10 | typedef struct _QuickSettingsGridAirplaneModeButton {
11 | // embedd this as first argument so we can cast to it.
12 | QuickSettingsGridButton button;
13 | } QuickSettingsGridAirplaneModeButton;
14 |
15 | QuickSettingsGridAirplaneModeButton *
16 | quick_settings_grid_airplane_mode_button_init();
17 |
18 | void quick_settings_grid_airplane_mode_button_free(
19 | QuickSettingsGridAirplaneModeButton *self);
20 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_button.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | enum QuickSettingsButtonType {
6 | QUICK_SETTINGS_BUTTON_GENERIC,
7 | QUICK_SETTINGS_BUTTON_ONESHOT,
8 | QUICK_SETTINGS_BUTTON_ETHERNET,
9 | QUICK_SETTINGS_BUTTON_WIFI,
10 | QUICK_SETTINGS_BUTTON_PERFORMANCE,
11 | QUICK_SETTINGS_BUTTON_IDLE_INHIBITOR,
12 | QUICK_SETTINGS_BUTTON_THEME,
13 | QUICK_SETTINGS_BUTTON_NIGHT_LIGHT,
14 | QUICK_SETTINGS_BUTTON_AIRPLANE_MODE,
15 | QUICK_SETTINGS_BUTTON_KEYBOARD_BRIGHTNESS,
16 | QUICK_SETTINGS_BUTTON_VPN,
17 | };
18 |
19 | typedef struct _QuickSettingsGridCluster QuickSettingsGridCluster;
20 | typedef struct _QuickSettingsGridButton QuickSettingsGridButton;
21 |
22 | // Callback function invoked when a QuickSettingCluster revealed the widget
23 | // associated with a QuickSettingsGridButton's reveal button click.
24 | typedef void (*QuickSettingsClusterOnRevealFunc)(
25 | QuickSettingsGridButton *revealed, gboolean is_revealed);
26 |
27 | typedef struct _QuickSettingsGridButton {
28 | QuickSettingsGridCluster *cluster;
29 | enum QuickSettingsButtonType type;
30 | GtkBox *container;
31 | GtkButton *toggle;
32 | GtkLabel *title;
33 | GtkLabel *subtitle;
34 | GtkImage *icon;
35 | GtkButton *reveal_button;
36 | GtkWidget *reveal_widget;
37 | GtkRevealer *revealer;
38 | QuickSettingsClusterOnRevealFunc on_reveal;
39 | } QuickSettingsGridButton;
40 |
41 | QuickSettingsGridButton *quick_settings_grid_button_new(
42 | enum QuickSettingsButtonType type, const gchar *title,
43 | const gchar *subtitle, const gchar *icon_name, GtkWidget *reveal_widget,
44 | QuickSettingsClusterOnRevealFunc on_reveal);
45 |
46 | void quick_settings_grid_button_init(
47 | QuickSettingsGridButton *self, enum QuickSettingsButtonType type,
48 | const gchar *title, const gchar *subtitle, const gchar *icon_name,
49 | GtkWidget *reveal_widget, QuickSettingsClusterOnRevealFunc on_reveal);
50 |
51 | // this just controls the CSS classes, such that 'true' makes the button look
52 | // enabled while 'false' looks disabled.
53 | //
54 | // buttons have multiple widgets so a method handles altering multiple widget's
55 | // css.
56 | void quick_settings_grid_button_set_toggled(QuickSettingsGridButton *self,
57 | gboolean toggled);
58 |
59 | void quick_settings_grid_button_free(QuickSettingsGridButton *self);
60 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_cluster.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "quick_settings_grid_button.h"
6 |
7 | enum QuickSettingsGridClusterSide {
8 | QUICK_SETTINGS_GRID_CLUSTER_NONE,
9 | QUICK_SETTINGS_GRID_CLUSTER_BOTH,
10 | QUICK_SETTINGS_GRID_CLUSTER_LEFT,
11 | QUICK_SETTINGS_GRID_CLUSTER_RIGHT,
12 | };
13 |
14 | G_BEGIN_DECLS
15 |
16 | // A QuickSettingsGridCluster consists of two QuickSettingsGridButtons layed out
17 | // side-by-side in a GtkCenterBox.
18 | //
19 | // The GtkCenterBox is placed on top of two GtkRevealers, one for the left, and
20 | // one for the right.
21 | //
22 | // If either QuickSettingsGridButton has a 'reveal' button it will be wired to
23 | // the appropriate GtkRevealer on it's click.
24 | struct _QuickSettingsGridCluster;
25 | #define QUICK_SETTINGS_GRID_CLUSTER_TYPE quick_settings_grid_cluster_get_type()
26 | G_DECLARE_FINAL_TYPE(QuickSettingsGridCluster, quick_settings_grid_cluster,
27 | QUICK_SETTINGS_GRID, CLUSTER, GObject);
28 |
29 | G_END_DECLS
30 |
31 | GtkWidget *quick_settings_grid_cluster_get_widget(
32 | QuickSettingsGridCluster *cluster);
33 |
34 | int quick_settings_grid_cluster_add_button(
35 | QuickSettingsGridCluster *cluster, enum QuickSettingsGridClusterSide side,
36 | QuickSettingsGridButton *button);
37 |
38 | gboolean quick_settings_grid_cluster_is_full(QuickSettingsGridCluster *cluster);
39 |
40 | enum QuickSettingsGridClusterSide quick_settings_grid_cluster_vacant_side(
41 | QuickSettingsGridCluster *cluster);
42 |
43 | GtkCenterBox *quick_settings_grid_cluster_get_center_box(
44 | QuickSettingsGridCluster *cluster);
45 |
46 | GtkRevealer *quick_settings_grid_cluster_get_left_revealer(
47 | QuickSettingsGridCluster *cluster);
48 |
49 | GtkRevealer *quick_settings_grid_cluster_get_right_revealer(
50 | QuickSettingsGridCluster *cluster);
51 |
52 | void quick_settings_grid_cluster_slide_left(QuickSettingsGridCluster *cluster);
53 |
54 | void quick_settings_grid_cluster_hide_all(QuickSettingsGridCluster *cluster);
55 |
56 | int quick_settings_grid_cluster_remove_button(QuickSettingsGridCluster *self,
57 | QuickSettingsGridButton *button);
58 |
59 | QuickSettingsGridButton *quick_settings_grid_cluster_get_left_button(
60 | QuickSettingsGridCluster *self);
61 |
62 | QuickSettingsGridButton *quick_settings_grid_cluster_get_right_button(
63 | QuickSettingsGridCluster *self);
64 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_ethernet.c:
--------------------------------------------------------------------------------
1 |
2 | #include "./quick_settings_grid_ethernet.h"
3 |
4 | #include
5 |
6 | #include "./quick_settings_grid_button.h"
7 | #include "nm-dbus-interface.h"
8 |
9 | static void on_state_changed_ether(NMDeviceEthernet *dev, GParamSpec *pspec,
10 | QuickSettingsGridEthernetButton *button) {
11 | char *name = "";
12 | char *icon = "";
13 | NMDeviceState state = 0;
14 |
15 | state = nm_device_get_state(NM_DEVICE(dev));
16 | switch (state) {
17 | case NM_DEVICE_STATE_UNKNOWN:
18 | case NM_DEVICE_STATE_UNMANAGED:
19 | case NM_DEVICE_STATE_UNAVAILABLE:
20 | case NM_DEVICE_STATE_DISCONNECTED:
21 | case NM_DEVICE_STATE_FAILED:
22 | case NM_DEVICE_STATE_DEACTIVATING:
23 | icon = "network-wired-disconnected-symbolic";
24 | name = "no network";
25 | break;
26 | case NM_DEVICE_STATE_PREPARE:
27 | case NM_DEVICE_STATE_CONFIG:
28 | case NM_DEVICE_STATE_NEED_AUTH:
29 | case NM_DEVICE_STATE_IP_CONFIG:
30 | case NM_DEVICE_STATE_IP_CHECK:
31 | case NM_DEVICE_STATE_SECONDARIES:
32 | icon = "network-wired-acquiring-symbolic";
33 | name = "no internet";
34 | break;
35 | default:
36 | icon = "network-wired-symbolic";
37 | name = "connected";
38 | break;
39 | }
40 |
41 | // update self->subtitle label with ap name
42 | gtk_label_set_text(button->button.subtitle, name);
43 | // set ellipsize
44 | gtk_label_set_ellipsize(button->button.subtitle, PANGO_ELLIPSIZE_END);
45 | // set max characters 10
46 | gtk_label_set_max_width_chars(button->button.subtitle, 12);
47 | // update icon
48 | gtk_image_set_from_icon_name(button->button.icon, icon);
49 | }
50 |
51 | void static on_state_changed(NMDevice *dev, guint new_state, guint old_state,
52 | guint reason,
53 | QuickSettingsGridEthernetButton *self) {
54 | switch (reason) {
55 | case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
56 | case NM_DEVICE_STATE_REASON_REMOVED:
57 | g_signal_emit_by_name(self->button.cluster, "remove_button_req",
58 | self);
59 | // we are removed from cluster at this point, free ourselves
60 | quick_settings_grid_ethernet_button_free(self);
61 | return;
62 | default:
63 | break;
64 | }
65 | on_state_changed_ether(NM_DEVICE_ETHERNET(dev), NULL, self);
66 | }
67 |
68 | QuickSettingsGridEthernetButton *quick_settings_grid_ethernet_button_init(
69 | NMDeviceEthernet *dev) {
70 | QuickSettingsGridEthernetButton *self =
71 | g_malloc0(sizeof(QuickSettingsGridEthernetButton));
72 |
73 | quick_settings_grid_button_init(&self->button,
74 | QUICK_SETTINGS_BUTTON_ETHERNET, "Wired", "",
75 | "network-wired-symbolic", NULL, NULL);
76 | self->dev = dev;
77 |
78 | NMDeviceStateReason reason = nm_device_get_state_reason(NM_DEVICE(dev));
79 | on_state_changed(NM_DEVICE(dev), 0, 0, reason, self);
80 |
81 | // Monitor state changes for ethernet.
82 | g_signal_connect(dev, "state-changed", G_CALLBACK(on_state_changed), self);
83 |
84 | g_object_ref(dev);
85 |
86 | return self;
87 | }
88 |
89 | void quick_settings_grid_ethernet_button_free(
90 | QuickSettingsGridEthernetButton *self) {
91 | // kill signal handlers
92 | g_signal_handlers_disconnect_by_func(self->dev, on_state_changed, self);
93 | // unref button's container
94 | g_object_unref(self->button.container);
95 | // free ourselves
96 | g_free(self);
97 | }
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_ethernet.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "quick_settings_grid_button.h"
5 |
6 | #define QUICK_SETTINGS_ETHERNET_TYPE "ethernet"
7 |
8 | typedef struct _QuickSettingsGridEthernetMenu QuickSettingsGridEthernetMenu;
9 |
10 | typedef struct _QuickSettingsGridEthernetButton {
11 | // embedd this as first argument so we can cast to it.
12 | QuickSettingsGridButton button;
13 | QuickSettingsGridEthernetMenu *menu;
14 | NMDeviceEthernet *dev;
15 | } QuickSettingsGridEthernetButton;
16 |
17 | QuickSettingsGridEthernetButton *quick_settings_grid_ethernet_button_init(
18 | NMDeviceEthernet *dev);
19 |
20 | void quick_settings_grid_ethernet_button_free(
21 | QuickSettingsGridEthernetButton *self);
22 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_idle_inhibitor.c:
--------------------------------------------------------------------------------
1 | #include "./quick_settings_grid_idle_inhibitor.h"
2 |
3 | #include
4 |
5 | #include "../../../services/logind_service/logind_service.h"
6 | #include "./quick_settings_grid_button.h"
7 |
8 | static void on_toggle_button_clicked(
9 | GtkButton *button, QuickSettingsGridIdleInhibitorButton *self) {
10 | g_debug(
11 | "quick_settings_grid_idle_inhibitor.c: on_toggle_button_clicked(): "
12 | "toggling idle inhibitor");
13 |
14 | LogindService *logind = logind_service_get_global();
15 |
16 | gboolean inhibit = logind_service_get_idle_inhibit(logind);
17 | if (!inhibit)
18 | logind_service_set_idle_inhibit(logind, true);
19 | else
20 | logind_service_set_idle_inhibit(logind, false);
21 | }
22 |
23 | static void on_idle_inhibit_changed(
24 | LogindService *logind_service, gboolean inhibited,
25 | QuickSettingsGridIdleInhibitorButton *self) {
26 | g_debug(
27 | "quick_settings_grid_idle_inhibitor.c: on_idle_inhibit_changed(): "
28 | "idle inhibitor changed: %d",
29 | inhibited);
30 |
31 | if (inhibited)
32 | quick_settings_grid_button_set_toggled(&self->button, true);
33 | else
34 | quick_settings_grid_button_set_toggled(&self->button, false);
35 | }
36 |
37 | QuickSettingsGridIdleInhibitorButton *
38 | quick_settings_grid_idle_inhibitor_button_init() {
39 | QuickSettingsGridIdleInhibitorButton *self =
40 | g_malloc0(sizeof(QuickSettingsGridIdleInhibitorButton));
41 |
42 | quick_settings_grid_button_init(
43 | &self->button, QUICK_SETTINGS_BUTTON_IDLE_INHIBITOR, "Idle Inhibitor",
44 | NULL, "radio-mixed-symbolic", NULL, NULL);
45 |
46 | g_signal_connect(self->button.toggle, "clicked",
47 | G_CALLBACK(on_toggle_button_clicked), self);
48 |
49 | // get initial inhibitor state
50 | LogindService *logind = logind_service_get_global();
51 | gboolean inhibit = logind_service_get_idle_inhibit(logind);
52 |
53 | on_idle_inhibit_changed(logind, inhibit, self);
54 |
55 | // listen for idle_inhibitor_changed
56 | g_signal_connect(logind, "idle-inhibitor-changed",
57 | G_CALLBACK(on_idle_inhibit_changed), self);
58 |
59 | return self;
60 | }
61 |
62 | void quick_settings_grid_inhibitor_button_free(
63 | QuickSettingsGridIdleInhibitorButton *self) {
64 | // unref button's container
65 | g_object_unref(self->button.container);
66 |
67 | // kill signals
68 | LogindService *logind = logind_service_get_global();
69 | g_signal_handlers_disconnect_by_func(logind, on_idle_inhibit_changed, self);
70 |
71 | // free ourselves
72 | g_free(self);
73 | }
74 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_idle_inhibitor.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "quick_settings_grid_button.h"
4 |
5 | #define QUICK_SETTINGS_IDLE_INHIBITOR_TYPE "idle_inhibitor"
6 |
7 | typedef struct _QuickSettingsGridIdleInhibitorMenu
8 | QuickSettingsGridIdleInhibitorMenu;
9 |
10 | typedef struct _QuickSettingsGridIdleInhibitorButton {
11 | // embedd this as first argument so we can cast to it.
12 | QuickSettingsGridButton button;
13 | } QuickSettingsGridIdleInhibitorButton;
14 |
15 | QuickSettingsGridIdleInhibitorButton *
16 | quick_settings_grid_idle_inhibitor_button_init();
17 |
18 | void quick_settings_grid_inhibitor_button_free(
19 | QuickSettingsGridIdleInhibitorButton *self);
20 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_night_light/quick_settings_grid_night_light.c:
--------------------------------------------------------------------------------
1 | #include "./quick_settings_grid_night_light.h"
2 |
3 | #include
4 |
5 | #include "../../../../services/wayland/gamma_control_service/gamma.h"
6 |
7 | void quick_settings_grid_night_light_button_layout(
8 | QuickSettingsGridNightLightButton *self) {
9 | // create associated menu
10 | self->menu = g_object_new(QUICK_SETTINGS_GRID_NIGHT_LIGHT_MENU_TYPE, NULL);
11 |
12 | quick_settings_grid_button_init(
13 | &self->button, QUICK_SETTINGS_BUTTON_NIGHT_LIGHT, "Night Light", NULL,
14 | "night-light-symbolic",
15 | quick_settings_grid_night_light_button_get_menu_widget(self),
16 | quick_settings_grid_night_light_menu_on_reveal);
17 | }
18 |
19 | static void on_gamma_control_enabled(WaylandGammaControlService *gamma,
20 | QuickSettingsGridNightLightButton *self) {
21 | quick_settings_grid_button_set_toggled(&self->button, true);
22 | }
23 |
24 | static void on_gamma_control_disabled(WaylandGammaControlService *gamma,
25 | QuickSettingsGridNightLightButton *self) {
26 | quick_settings_grid_button_set_toggled(&self->button, false);
27 | }
28 |
29 | static void on_toggle_button_clicked(GtkButton *button,
30 | QuickSettingsGridNightLightButton *self) {
31 | g_debug(
32 | "quick_settings_grid_night_light.c: on_toggle_button_clicked(): "
33 | "toggling night light");
34 |
35 | GtkScale *temp_scale =
36 | quick_settings_grid_night_light_menu_get_temp_scale(self->menu);
37 |
38 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
39 |
40 | gboolean enabled = wayland_gamma_control_service_enabled(w);
41 | if (!enabled) {
42 | wayland_gamma_control_service_set_temperature(
43 | w, gtk_range_get_value(GTK_RANGE(temp_scale)));
44 | } else {
45 | // reset scale value to 3000k
46 | gtk_range_set_value(GTK_RANGE(temp_scale), 3000);
47 | wayland_gamma_control_service_destroy(w);
48 | }
49 | }
50 |
51 | QuickSettingsGridNightLightButton *
52 | quick_settings_grid_night_light_button_init() {
53 | QuickSettingsGridNightLightButton *self =
54 | g_malloc0(sizeof(QuickSettingsGridNightLightButton));
55 |
56 | quick_settings_grid_night_light_button_layout(self);
57 |
58 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
59 | g_signal_connect(w, "gamma-control-enabled",
60 | G_CALLBACK(on_gamma_control_enabled), self);
61 | g_signal_connect(w, "gamma-control-disabled",
62 | G_CALLBACK(on_gamma_control_disabled), self);
63 |
64 | gboolean enabled = wayland_gamma_control_service_enabled(w);
65 | if (enabled) {
66 | quick_settings_grid_button_set_toggled(&self->button, true);
67 | } else {
68 | quick_settings_grid_button_set_toggled(&self->button, false);
69 | }
70 |
71 | g_signal_connect(self->button.toggle, "clicked",
72 | G_CALLBACK(on_toggle_button_clicked), self);
73 |
74 | return self;
75 | }
76 |
77 | GtkWidget *quick_settings_grid_night_light_button_get_menu_widget(
78 | QuickSettingsGridNightLightButton *self) {
79 | return GTK_WIDGET(
80 | quick_settings_grid_night_light_menu_get_widget(self->menu));
81 | }
82 |
83 | void quick_settings_grid_night_light_button_free(
84 | QuickSettingsGridNightLightButton *self) {
85 | g_debug(
86 | "quick_settings_grid_night_light.c:qs_grid_night_light_button_free() "
87 | "called");
88 |
89 | // kill gamma control signals
90 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
91 | g_signal_handlers_disconnect_by_data(w, self);
92 |
93 | // free ourselves
94 | g_free(self);
95 | }
96 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_night_light/quick_settings_grid_night_light.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_night_light_menu.h"
8 |
9 | #define QUICK_SETTINGS_NIGHT_LIGHT_TYPE "night-light"
10 |
11 | typedef struct _QuickSesstingsGridNightLightButton {
12 | // embedd this as first argument so we can cast to it.
13 | QuickSettingsGridButton button;
14 | QuickSettingsGridNightLightMenu *menu;
15 | gboolean enabled;
16 |
17 | } QuickSettingsGridNightLightButton;
18 |
19 | QuickSettingsGridNightLightButton *quick_settings_grid_night_light_button_init();
20 |
21 | void quick_settings_grid_night_light_button_free(QuickSettingsGridNightLightButton *self);
22 |
23 | GtkWidget *quick_settings_grid_night_light_button_get_menu_widget(
24 | QuickSettingsGridNightLightButton *self);
25 |
26 | void quick_settings_grid_night_light_menu_on_reveal(
27 | QuickSettingsGridButton *button, gboolean is_revealed);
28 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_night_light/quick_settings_grid_night_light_menu.c:
--------------------------------------------------------------------------------
1 | #include "quick_settings_grid_night_light_menu.h"
2 |
3 | #include
4 |
5 | #include "../../../../services/wayland/gamma_control_service/gamma.h"
6 | #include "../../quick_settings_menu_widget.h"
7 | #include "gtk/gtk.h"
8 | #include "quick_settings_grid_night_light.h"
9 |
10 | enum signals { signals_n };
11 |
12 | typedef struct _QuickSettingsGridNightLightMenu {
13 | GObject parent_instance;
14 | QuickSettingsMenuWidget menu;
15 | GtkScale *temp_slider;
16 | } QuickSettingsGridNightLightMenu;
17 | G_DEFINE_TYPE(QuickSettingsGridNightLightMenu,
18 | quick_settings_grid_night_light_menu, G_TYPE_OBJECT);
19 |
20 | // stub out dispose, finalize, init and class init functions for GObject
21 | static void quick_settings_grid_night_light_menu_dispose(GObject *object) {
22 | QuickSettingsGridNightLightMenu *self =
23 | QUICK_SETTINGS_GRID_NIGHT_LIGHT_MENU(object);
24 | }
25 |
26 | static void quick_settings_grid_night_light_menu_finalize(GObject *object) {}
27 |
28 | static void quick_settings_grid_night_light_menu_class_init(
29 | QuickSettingsGridNightLightMenuClass *klass) {
30 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
31 | object_class->dispose = quick_settings_grid_night_light_menu_dispose;
32 | object_class->finalize = quick_settings_grid_night_light_menu_finalize;
33 | }
34 |
35 | static void on_value_changed(GtkRange *range,
36 | QuickSettingsGridNightLightMenu *self) {
37 | g_debug("quick_settings_grid_night_light_menu.c:on_value_changed() called");
38 |
39 | WaylandGammaControlService *w = wayland_gamma_control_service_get_global();
40 | wayland_gamma_control_service_set_temperature(w,
41 | gtk_range_get_value(range));
42 | }
43 |
44 | static void quick_settings_grid_night_light_menu_init_layout(
45 | QuickSettingsGridNightLightMenu *self) {
46 | quick_settings_menu_widget_init(&self->menu, false);
47 | gtk_image_set_from_icon_name(self->menu.icon, "night-light-symbolic");
48 | gtk_label_set_text(self->menu.title, "Temperature");
49 |
50 | // create temperature scale
51 | self->temp_slider = GTK_SCALE(
52 | gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 1000, 6800, 500));
53 |
54 | for (int i = 1000; i <= 6000; i += 1000) {
55 | char *str = g_strdup_printf("%dK", i / 1000);
56 | gtk_scale_add_mark(self->temp_slider, i, GTK_POS_BOTTOM, str);
57 | g_free(str);
58 | }
59 | gtk_scale_add_mark(self->temp_slider, 6800, GTK_POS_BOTTOM, "68K");
60 |
61 | gtk_range_set_value(GTK_RANGE(self->temp_slider), 3000);
62 |
63 | // connect signal
64 | g_signal_connect(self->temp_slider, "value-changed",
65 | G_CALLBACK(on_value_changed), self);
66 |
67 | gtk_box_append(self->menu.options, GTK_WIDGET(self->temp_slider));
68 | }
69 |
70 | static void quick_settings_grid_night_light_menu_init(
71 | QuickSettingsGridNightLightMenu *self) {
72 | quick_settings_grid_night_light_menu_init_layout(self);
73 | }
74 |
75 | void quick_settings_grid_night_light_menu_on_reveal(
76 | QuickSettingsGridButton *button_, gboolean is_revealed) {
77 | QuickSettingsGridNightLightButton *button =
78 | (QuickSettingsGridNightLightButton *)button_;
79 | QuickSettingsGridNightLightMenu *self = button->menu;
80 | g_debug("quick_settings_grid_night_light_menu.c:on_reveal() called");
81 | }
82 |
83 | GtkWidget *quick_settings_grid_night_light_menu_get_widget(
84 | QuickSettingsGridNightLightMenu *self) {
85 | return GTK_WIDGET(self->menu.container);
86 | }
87 |
88 | GtkScale *quick_settings_grid_night_light_menu_get_temp_scale(
89 | QuickSettingsGridNightLightMenu *grid) {
90 | return grid->temp_slider;
91 | }
92 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_night_light/quick_settings_grid_night_light_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _QuickSettingsGridNightLightMenu;
9 | #define QUICK_SETTINGS_GRID_NIGHT_LIGHT_MENU_TYPE \
10 | quick_settings_grid_night_light_menu_get_type()
11 | G_DECLARE_FINAL_TYPE(QuickSettingsGridNightLightMenu,
12 | quick_settings_grid_night_light_menu, QUICK_SETTINGS,
13 | GRID_NIGHT_LIGHT_MENU, GObject);
14 |
15 | G_END_DECLS
16 |
17 | GtkScale *quick_settings_grid_night_light_menu_get_temp_scale(
18 | QuickSettingsGridNightLightMenu *grid);
19 |
20 | GtkWidget *quick_settings_grid_night_light_menu_get_widget(
21 | QuickSettingsGridNightLightMenu *grid);
22 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_oneshot_button.c:
--------------------------------------------------------------------------------
1 | #include "quick_settings_grid_oneshot_button.h"
2 |
3 | #include
4 |
5 | #include "quick_settings_grid_button.h"
6 |
7 | static void on_clicked(GtkButton *button, QuickSettingsGridButton *self) {
8 | if (self->cluster)
9 | // emit cluster remove button req to remove ourselves.
10 | g_signal_emit_by_name(self->cluster, "remove_button_req", self);
11 | }
12 |
13 | void quick_settings_grid_oneshot_button_init_layout(
14 | QuickSettingsGridOneShotButton *self, const char *title,
15 | const char *subtitle, const char *icon) {
16 | quick_settings_grid_button_init(&self->button,
17 | QUICK_SETTINGS_BUTTON_ONESHOT, title,
18 | subtitle, icon, NULL, NULL);
19 |
20 | // wire button click
21 | g_signal_connect(self->button.toggle, "clicked", G_CALLBACK(on_clicked),
22 | self);
23 | }
24 |
25 | QuickSettingsGridOneShotButton *quick_settings_grid_oneshot_button_init(
26 | const char *title, const char *subtitle, const char *icon) {
27 | QuickSettingsGridOneShotButton *self =
28 | g_malloc0(sizeof(QuickSettingsGridOneShotButton));
29 | quick_settings_grid_oneshot_button_init_layout(self, title, subtitle, icon);
30 | return self;
31 | }
32 |
33 | void quick_settings_grid_oneshot_button_free(
34 | QuickSettingsGridOneShotButton *self);
35 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_oneshot_button.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "quick_settings_grid_button.h"
4 |
5 | // A simple QuickSettingsGridButton which removes itself from the cluster once
6 | // clicked.
7 | typedef struct _QuickSettingsGridOneShotButton {
8 | // embedd this as first argument so we can cast to it.
9 | QuickSettingsGridButton button;
10 | } QuickSettingsGridOneShotButton;
11 |
12 | QuickSettingsGridOneShotButton *quick_settings_grid_oneshot_button_init(
13 | const char *title, const char *subtitle, const char *icon);
14 |
15 | void quick_settings_grid_oneshot_button_free(
16 | QuickSettingsGridOneShotButton *self);
17 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_power_profiles/quick_settings_grid_power_profiles.c:
--------------------------------------------------------------------------------
1 | #include "./quick_settings_grid_power_profiles.h"
2 |
3 | #include
4 |
5 | #include "../../../../services/power_profiles_service/power_profiles_service.h"
6 | #include "./../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_power_profiles_menu.h"
8 |
9 | static void on_active_profile_change(
10 | PowerProfilesService *pps, char *power_profile,
11 | QuickSettingsGridPowerProfilesButton *self) {
12 | gtk_label_set_text(self->button.subtitle, power_profile);
13 |
14 | const char *icon = power_profiles_service_profile_to_icon(power_profile);
15 | gtk_image_set_from_icon_name(self->button.icon, icon);
16 |
17 | // on selection of a new profile simulate a revealer button click which
18 | // closes the menu.
19 | if (gtk_revealer_get_child_revealed(self->button.revealer)) {
20 | g_signal_emit_by_name(G_OBJECT(self->button.reveal_button), "clicked");
21 | }
22 | }
23 |
24 | void quick_settings_grid_power_profiles_button_layout(
25 | QuickSettingsGridPowerProfilesButton *self) {
26 | // get power profiles service
27 | PowerProfilesService *power_profiles_service =
28 | power_profiles_service_get_global();
29 |
30 | // get active profile for subtitle and icon
31 | const gchar *active_profile =
32 | power_profiles_service_get_active_profile(power_profiles_service);
33 |
34 | const char *icon = power_profiles_service_profile_to_icon(active_profile);
35 | quick_settings_grid_button_init(
36 | &self->button, QUICK_SETTINGS_BUTTON_PERFORMANCE, "Performance",
37 | active_profile, icon,
38 | quick_settings_grid_power_profiles_button_get_menu_widget(self), NULL);
39 |
40 | // attach to active profile changed event
41 | g_signal_connect(power_profiles_service, "active-profile-changed",
42 | G_CALLBACK(on_active_profile_change), self);
43 | }
44 |
45 | QuickSettingsGridPowerProfilesButton *
46 | quick_settings_grid_power_profiles_button_init() {
47 | QuickSettingsGridPowerProfilesButton *self =
48 | g_malloc0(sizeof(QuickSettingsGridPowerProfilesButton));
49 |
50 | self->menu =
51 | g_object_new(QUICK_SETTINGS_GRID_POWER_PROFILES_MENU_TYPE, NULL);
52 |
53 | quick_settings_grid_power_profiles_button_layout(self);
54 |
55 | return self;
56 | }
57 |
58 | GtkWidget *quick_settings_grid_power_profiles_button_get_menu_widget(
59 | QuickSettingsGridPowerProfilesButton *self) {
60 | return GTK_WIDGET(
61 | quick_settings_grid_power_profiles_menu_get_widget(self->menu));
62 | }
63 |
64 | void quick_settings_grid_power_profiles_button_free(
65 | QuickSettingsGridPowerProfilesButton *self) {
66 | g_debug(
67 | "quick_settings_grid_power_profiles.c:qs_grid_power_profiles_button_"
68 | "free() called");
69 |
70 | // kill signals
71 | g_signal_handlers_disconnect_by_func(power_profiles_service_get_global(),
72 | on_active_profile_change, self);
73 |
74 | // unref our menu
75 | g_object_unref(self->menu);
76 | // unref button's container
77 | g_object_unref(self->button.container);
78 | // free ourselves
79 | g_free(self);
80 | }
81 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_power_profiles/quick_settings_grid_power_profiles.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_power_profiles_menu.h"
8 |
9 | #define QUICK_SETTINGS_POWER_PROFILES_TYPE "power-profiles"
10 |
11 | typedef struct _QuickSesstingsGridPowerProfilesButton {
12 | // embedd this as first argument so we can cast to it.
13 | QuickSettingsGridButton button;
14 | QuickSettingsGridPowerProfilesMenu *menu;
15 | } QuickSettingsGridPowerProfilesButton;
16 |
17 | QuickSettingsGridPowerProfilesButton *
18 | quick_settings_grid_power_profiles_button_init();
19 |
20 | void quick_settings_grid_power_profiles_button_free(
21 | QuickSettingsGridPowerProfilesButton *self);
22 |
23 | GtkWidget *quick_settings_grid_power_profiles_button_get_menu_widget(
24 | QuickSettingsGridPowerProfilesButton *self);
25 |
26 | void quick_settings_grid_power_profiles_menu_on_reveal(
27 | QuickSettingsGridButton *button, gboolean is_revealed);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_power_profiles/quick_settings_grid_power_profiles_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettingsGridPowerProfilesMenu;
8 | #define QUICK_SETTINGS_GRID_POWER_PROFILES_MENU_TYPE \
9 | quick_settings_grid_power_profiles_menu_get_type()
10 | G_DECLARE_FINAL_TYPE(QuickSettingsGridPowerProfilesMenu, quick_settings_grid_power_profiles_menu,
11 | QUICK_SETTINGS, GRID_POWER_PROFILES_MENU, GObject);
12 |
13 | G_END_DECLS
14 |
15 | GtkWidget *quick_settings_grid_power_profiles_menu_get_widget(
16 | QuickSettingsGridPowerProfilesMenu *self);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_theme.c:
--------------------------------------------------------------------------------
1 | #include "quick_settings_grid_theme.h"
2 |
3 | #include
4 |
5 | #include "../../../services/theme_service.h"
6 | #include "quick_settings_grid_button.h"
7 |
8 | static void on_toggle_button_clicked(GtkButton *button, QuickSettingsGridButton *self) {
9 | ThemeService *ts = theme_service_get_global();
10 | enum ThemeServiceTheme theme = theme_service_get_theme(ts);
11 | if (theme == THEME_LIGHT) {
12 | theme_service_set_dark_theme(ts, TRUE);
13 | } else {
14 | theme_service_set_light_theme(ts, TRUE);
15 | }
16 | }
17 |
18 | static void on_theme_changed(ThemeService *ts, enum ThemeServiceTheme theme,
19 | QuickSettingsGridButton *self) {
20 | if (theme == THEME_LIGHT) {
21 | quick_settings_grid_button_set_toggled(self, false);
22 | } else {
23 | quick_settings_grid_button_set_toggled(self, true);
24 | }
25 | }
26 |
27 | void quick_settings_grid_theme_button_init_layout(
28 | QuickSettingsGridOneThemeButton *self) {
29 | quick_settings_grid_button_init(
30 | &self->button, QUICK_SETTINGS_BUTTON_THEME, "Dark Mode", NULL,
31 | "preferences-desktop-appearance-symbolic", NULL, NULL);
32 |
33 | ThemeService *ts = theme_service_get_global();
34 | enum ThemeServiceTheme theme = theme_service_get_theme(ts);
35 | on_theme_changed(ts, theme, &self->button);
36 |
37 | g_signal_connect(ts, "theme-changed", G_CALLBACK(on_theme_changed),
38 | &self->button);
39 |
40 | // wire button click
41 | g_signal_connect(self->button.toggle, "clicked", G_CALLBACK(on_toggle_button_clicked),
42 | self);
43 | }
44 |
45 | QuickSettingsGridOneThemeButton *quick_settings_grid_theme_button_init() {
46 | QuickSettingsGridOneThemeButton *self =
47 | g_malloc0(sizeof(QuickSettingsGridOneThemeButton));
48 | quick_settings_grid_theme_button_init_layout(self);
49 | return self;
50 | }
51 |
52 | void quick_settings_grid_theme_button_free(
53 | QuickSettingsGridOneThemeButton *self) {
54 | g_signal_handlers_disconnect_by_func(theme_service_get_global(),
55 | on_theme_changed, self);
56 | }
57 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_theme.h:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 | #include "quick_settings_grid_button.h"
5 |
6 | typedef struct _QuickSettingsGridOneThemeButton {
7 | // embedd this as first argument so we can cast to it.
8 | QuickSettingsGridButton button;
9 | } QuickSettingsGridOneThemeButton;
10 |
11 | QuickSettingsGridOneThemeButton *quick_settings_grid_theme_button_init();
12 |
13 | void quick_settings_grid_theme_button_free(
14 | QuickSettingsGridOneThemeButton *self);
15 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_vpn/quick_settings_grid_vpn.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_vpn_menu.h"
8 |
9 | #define QUICK_SETTINGS_VPN_TYPE "vpn"
10 |
11 | typedef struct _QuickSesstingsGridVPNButton {
12 | // embedd this as first argument so we can cast to it.
13 | QuickSettingsGridButton button;
14 | QuickSettingsGridVPNMenu *menu;
15 | gboolean enabled;
16 | GPtrArray *active_stack;
17 |
18 | } QuickSettingsGridVPNButton;
19 |
20 | QuickSettingsGridVPNButton *quick_settings_grid_vpn_button_init();
21 |
22 | void quick_settings_grid_vpn_button_free(QuickSettingsGridVPNButton *self);
23 |
24 | GtkWidget *quick_settings_grid_vpn_button_get_menu_widget(
25 | QuickSettingsGridVPNButton *self);
26 |
27 | void quick_settings_grid_vpn_menu_on_reveal(
28 | QuickSettingsGridButton *button, gboolean is_revealed);
29 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_vpn/quick_settings_grid_vpn_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _QuickSettingsGridVPNMenu;
9 | #define QUICK_SETTINGS_GRID_VPN_MENU_TYPE \
10 | quick_settings_grid_vpn_menu_get_type()
11 | G_DECLARE_FINAL_TYPE(QuickSettingsGridVPNMenu, quick_settings_grid_vpn_menu,
12 | QUICK_SETTINGS, GRID_VPN_MENU, GObject);
13 |
14 | G_END_DECLS
15 |
16 | GtkWidget *quick_settings_grid_vpn_menu_get_widget(
17 | QuickSettingsGridVPNMenu *grid);
18 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_wifi/quick_settings_grid_wifi.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_wifi_menu.h"
8 |
9 | #define QUICK_SETTINGS_WIFI_TYPE "wifi"
10 |
11 | typedef struct _QuickSesstingsGridWifiButton {
12 | // embedd this as first argument so we can cast to it.
13 | QuickSettingsGridButton button;
14 | QuickSettingsGridWifiMenu *menu;
15 | NMDeviceWifi *dev;
16 | gboolean enabled;
17 |
18 | } QuickSettingsGridWifiButton;
19 |
20 | QuickSettingsGridWifiButton *quick_settings_grid_wifi_button_init(
21 | NMDeviceWifi *dev);
22 |
23 | void quick_settings_grid_wifi_button_free(QuickSettingsGridWifiButton *self);
24 |
25 | GtkWidget *quick_settings_grid_wifi_button_get_menu_widget(
26 | QuickSettingsGridWifiButton *self);
27 |
28 | void quick_settings_grid_wifi_menu_on_reveal(
29 | QuickSettingsGridButton *button, gboolean is_revealed);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_wifi/quick_settings_grid_wifi_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _QuickSettingsGridWifiMenu;
9 | #define QUICK_SETTINGS_GRID_WIFI_MENU_TYPE \
10 | quick_settings_grid_wifi_menu_get_type()
11 | G_DECLARE_FINAL_TYPE(QuickSettingsGridWifiMenu, quick_settings_grid_wifi_menu,
12 | QUICK_SETTINGS, GRID_WIFI_MENU, GObject);
13 |
14 | G_END_DECLS
15 |
16 | void quick_settings_grid_wifi_menu_set_device(QuickSettingsGridWifiMenu *grid,
17 | NMDeviceWifi *dev);
18 |
19 | GtkWidget *quick_settings_grid_wifi_menu_get_widget(
20 | QuickSettingsGridWifiMenu *grid);
21 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_grid_wifi/quick_settings_grid_wifi_menu_option.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | G_BEGIN_DECLS
5 |
6 | struct _QuickSettingsGridWifiMenuOption;
7 | #define QUICK_SETTINGS_GRID_WIFI_MENU_OPTION_TYPE \
8 | quick_settings_grid_wifi_menu_option_get_type()
9 | G_DECLARE_FINAL_TYPE(QuickSettingsGridWifiMenuOption,
10 | quick_settings_grid_wifi_menu_option, QUICK_SETTINGS,
11 | GRID_WIFI_MENU_OPTION, GObject);
12 |
13 | G_END_DECLS
14 |
15 | typedef struct _QuickSettingsGridWifiMenu QuickSettingsGridWifiMenu;
16 |
17 | GtkWidget *quick_settings_grid_wifi_menu_option_get_widget(
18 | QuickSettingsGridWifiMenuOption *self);
19 |
20 | void quick_settings_grid_wifi_menu_option_set_ap(
21 | QuickSettingsGridWifiMenuOption *self, QuickSettingsGridWifiMenu *menu,
22 | NMDeviceWifi *dev, NMAccessPoint *ap);
23 |
24 | // ap getter
25 | NMAccessPoint *quick_settings_grid_wifi_menu_option_get_ap(
26 | QuickSettingsGridWifiMenuOption *self);
27 |
28 | // device getter
29 | NMDeviceWifi *quick_settings_grid_wifi_menu_option_get_device(
30 | QuickSettingsGridWifiMenuOption *self);
31 |
32 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_keyboard_brightness/quick_settings_grid_keyboard_brightness.c:
--------------------------------------------------------------------------------
1 | #include "./quick_settings_grid_keyboard_brightness.h"
2 |
3 | #include
4 |
5 | #include "../../../../services/brightness_service/brightness_service.h"
6 | #include "glib-object.h"
7 |
8 | void quick_settings_grid_keyboard_brightness_button_layout(
9 | QuickSettingsGridKeyboardBrightnessButton *self) {
10 | // create associated menu
11 | self->menu =
12 | g_object_new(QUICK_SETTINGS_GRID_KEYBOARD_BRIGHTNESS_MENU_TYPE, NULL);
13 |
14 | quick_settings_grid_button_init(
15 | &self->button, QUICK_SETTINGS_BUTTON_KEYBOARD_BRIGHTNESS, "Keyboard",
16 | NULL, "keyboard-brightness-symbolic",
17 | quick_settings_grid_keyboard_brightness_button_get_menu_widget(self),
18 | quick_settings_grid_keyboard_brightness_menu_on_reveal);
19 | }
20 |
21 | static void on_toggle_button_clicked(
22 | GtkButton *button, QuickSettingsGridKeyboardBrightnessButton *self) {
23 | g_debug(
24 | "quick_settings_grid_keyboard_brightness.c: "
25 | "on_toggle_button_clicked(): "
26 | "toggling keyboard backlight");
27 |
28 | BrightnessService *bs = brightness_service_get_global();
29 | guint keyboard_brightness = brightness_service_get_keyboard(bs);
30 |
31 | if (keyboard_brightness > 0)
32 | brightness_service_set_keyboard(bs, 0);
33 | else
34 | brightness_service_set_keyboard(bs, 1);
35 | }
36 |
37 | static void on_keyboard_brightness_changed(
38 | BrightnessService *bs, guint keyboard_brightness,
39 | QuickSettingsGridKeyboardBrightnessButton *self) {
40 | g_debug(
41 | "quick_settings_grid_keyboard_brightness.c: "
42 | "on_keyboard_brightness_changed(): "
43 | "keyboard_brightness = %d",
44 | keyboard_brightness);
45 |
46 | if (keyboard_brightness > 0)
47 | quick_settings_grid_button_set_toggled(&self->button, TRUE);
48 | else
49 | quick_settings_grid_button_set_toggled(&self->button, FALSE);
50 | }
51 |
52 | QuickSettingsGridKeyboardBrightnessButton *
53 | quick_settings_grid_keyboard_brightness_button_init() {
54 | QuickSettingsGridKeyboardBrightnessButton *self =
55 | g_malloc0(sizeof(QuickSettingsGridKeyboardBrightnessButton));
56 |
57 | quick_settings_grid_keyboard_brightness_button_layout(self);
58 |
59 | BrightnessService *bs = brightness_service_get_global();
60 |
61 | guint keyboard_brightness = brightness_service_get_keyboard(bs);
62 | on_keyboard_brightness_changed(bs, keyboard_brightness, self);
63 |
64 | g_signal_connect(self->button.toggle, "clicked",
65 | G_CALLBACK(on_toggle_button_clicked), self);
66 | g_signal_connect(bs, "keyboard-brightness-changed",
67 | G_CALLBACK(on_keyboard_brightness_changed), self);
68 |
69 | return self;
70 | }
71 |
72 | GtkWidget *quick_settings_grid_keyboard_brightness_button_get_menu_widget(
73 | QuickSettingsGridKeyboardBrightnessButton *self) {
74 | return GTK_WIDGET(
75 | quick_settings_grid_keyboard_brightness_menu_get_widget(self->menu));
76 | }
77 |
78 | void quick_settings_grid_keyboard_brightness_button_free(
79 | QuickSettingsGridKeyboardBrightnessButton *self) {
80 | g_debug(
81 | "quick_settings_grid_keyboard_brightness.c:qs_grid_keyboard_brightness_"
82 | "button_free() "
83 | "called");
84 |
85 | // kill signals
86 | BrightnessService *bs = brightness_service_get_global();
87 | g_signal_handlers_disconnect_by_func(bs, on_keyboard_brightness_changed,
88 | self);
89 |
90 | // unref menu
91 | g_object_unref(self->menu);
92 |
93 | // free ourselves
94 | g_free(self);
95 | }
96 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_keyboard_brightness/quick_settings_grid_keyboard_brightness.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "../quick_settings_grid_button.h"
7 | #include "quick_settings_grid_keyboard_brightness_menu.h"
8 |
9 | #define QUICK_SETTINGS_KEYBOARD_BRIGHTNESS_TYPE "keyboard-brightness"
10 |
11 | typedef struct _QuickSesstingsGridKeyboardBrightnessButton {
12 | // embedd this as first argument so we can cast to it.
13 | QuickSettingsGridButton button;
14 | QuickSettingsGridKeyboardBrightnessMenu *menu;
15 | gboolean enabled;
16 |
17 | } QuickSettingsGridKeyboardBrightnessButton;
18 |
19 | QuickSettingsGridKeyboardBrightnessButton *
20 | quick_settings_grid_keyboard_brightness_button_init();
21 |
22 | void quick_settings_grid_keyboard_brightness_button_free(
23 | QuickSettingsGridKeyboardBrightnessButton *self);
24 |
25 | GtkWidget *quick_settings_grid_keyboard_brightness_button_get_menu_widget(
26 | QuickSettingsGridKeyboardBrightnessButton *self);
27 |
28 | void quick_settings_grid_keyboard_brightness_menu_on_reveal(
29 | QuickSettingsGridButton *button, gboolean is_revealed);
30 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_grid/quick_settings_keyboard_brightness/quick_settings_grid_keyboard_brightness_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _QuickSettingsGridKeyboardBrightnessMenu;
9 | #define QUICK_SETTINGS_GRID_KEYBOARD_BRIGHTNESS_MENU_TYPE \
10 | quick_settings_grid_keyboard_brightness_menu_get_type()
11 | G_DECLARE_FINAL_TYPE(QuickSettingsGridKeyboardBrightnessMenu,
12 | quick_settings_grid_keyboard_brightness_menu, QUICK_SETTINGS,
13 | GRID_KEYBOARD_BRIGHTNESS_MENU, GObject);
14 |
15 | G_END_DECLS
16 |
17 | GtkScale *quick_settings_grid_keyboard_brightness_menu_get_temp_scale(
18 | QuickSettingsGridKeyboardBrightnessMenu *grid);
19 |
20 | GtkWidget *quick_settings_grid_keyboard_brightness_menu_get_widget(
21 | QuickSettingsGridKeyboardBrightnessMenu *grid);
22 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_battery_button.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettingsBatteryButton;
8 | #define QUICK_SETTINGS_BATTERY_BUTTON_TYPE \
9 | quick_settings_battery_button_get_type()
10 | G_DECLARE_FINAL_TYPE(QuickSettingsBatteryButton, quick_settings_battery_button,
11 | QUICK_SETTINGS, BATTERY_BUTTON, GObject);
12 |
13 | G_END_DECLS
14 |
15 | void quick_settings_battery_button_reinitialize(
16 | QuickSettingsBatteryButton *self);
17 |
18 | GtkWidget *quick_settings_battery_button_get_widget(
19 | QuickSettingsBatteryButton *self);
20 |
21 | GtkButton *quick_settings_battery_button_get_button(
22 | QuickSettingsBatteryButton *self);
23 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_battery_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettingsBatteryMenu;
8 | #define QUICK_SETTINGS_BATTERY_MENU_TYPE quick_settings_battery_menu_get_type()
9 | G_DECLARE_FINAL_TYPE(QuickSettingsBatteryMenu, quick_settings_battery_menu,
10 | QUICK_SETTINGS, BATTERY_MENU, GObject);
11 |
12 | G_END_DECLS
13 |
14 | // Called to reinitialize the widget without allocating a new one.
15 | void quick_settings_battery_menu_reinitialize(QuickSettingsBatteryMenu *self);
16 |
17 | GtkWidget *quick_settings_battery_menu_get_widget(QuickSettingsBatteryMenu *self);
18 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_header.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _QuickSettingsHeader;
6 | #define QUICK_SETTINGS_HEADER_TYPE quick_settings_header_get_type()
7 | G_DECLARE_FINAL_TYPE(QuickSettingsHeader, quick_settings_header, QUICK_SETTINGS,
8 | HEADER, GObject);
9 |
10 | G_END_DECLS
11 |
12 | void quick_settings_header_reinitialize(QuickSettingsHeader *self);
13 |
14 | GtkWidget *quick_settings_header_get_widget(QuickSettingsHeader *self);
15 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_header_mixer/quick_settings_header_mixer.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _QuickSettingsHeaderMixer;
6 | #define QUICK_SETTINGS_HEADER_MIXER_TYPE quick_settings_header_mixer_get_type()
7 | G_DECLARE_FINAL_TYPE(QuickSettingsHeaderMixer, quick_settings_header_mixer,
8 | QUICK_SETTINGS, HEADER_MIXER, GObject);
9 |
10 | G_END_DECLS
11 |
12 | void quick_settings_header_mixer_reinitialize(QuickSettingsHeaderMixer *self);
13 |
14 | GtkButton *quick_settings_header_mixer_get_mixer_button(
15 | QuickSettingsHeaderMixer *self);
16 |
17 | GtkWidget *quick_settings_header_mixer_get_widget(
18 | QuickSettingsHeaderMixer *self);
19 |
20 | GtkWidget *quick_settings_header_mixer_get_menu_widget(
21 | QuickSettingsHeaderMixer *self);
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_header_mixer/quick_settings_header_mixer_menu_option.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "../../../../services/wireplumber_service.h"
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettingsHeaderMixerMenuOption;
8 | #define QUICK_SETTINGS_HEADER_MIXER_MENU_OPTION_TYPE \
9 | quick_settings_header_mixer_menu_option_get_type()
10 | G_DECLARE_FINAL_TYPE(QuickSettingsHeaderMixerMenuOption,
11 | quick_settings_header_mixer_menu_option, QUICK_SETTINGS,
12 | HEADER_MIXER_MENU_OPTION, GObject);
13 |
14 | G_END_DECLS
15 |
16 | GtkWidget *quick_settings_header_mixer_menu_option_get_widget(
17 | QuickSettingsHeaderMixerMenuOption *self);
18 |
19 | void quick_settings_header_mixer_menu_option_set_node(
20 | QuickSettingsHeaderMixerMenuOption *self,
21 | WirePlumberServiceNodeHeader *node);
22 |
23 | WirePlumberServiceNodeHeader *quick_settings_header_mixer_menu_option_get_node(
24 | QuickSettingsHeaderMixerMenuOption *self);
25 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_header/quick_settings_power_menu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _QuickSettingsPowerMenu;
8 | #define QUICK_SETTINGS_POWER_MENU_TYPE quick_settings_power_menu_get_type()
9 | G_DECLARE_FINAL_TYPE(QuickSettingsPowerMenu, quick_settings_power_menu,
10 | QUICK_SETTINGS, POWER_MENU, GObject);
11 |
12 | G_END_DECLS
13 |
14 | // Called to reinitialize the widget without allocating a new one.
15 | void quick_settings_power_menu_reinitialize(QuickSettingsPowerMenu *self);
16 |
17 | GtkWidget *quick_settings_power_menu_get_widget(QuickSettingsPowerMenu *self);
18 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_menu_widget.c:
--------------------------------------------------------------------------------
1 | #include "quick_settings_menu_widget.h"
2 |
3 | void quick_settings_menu_widget_init(QuickSettingsMenuWidget *self,
4 | gboolean scrolling) {
5 | // create container for entire widget
6 | self->container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
7 | gtk_widget_set_name(GTK_WIDGET(self->container), "quick-settings-menu");
8 | gtk_widget_set_vexpand(GTK_WIDGET(self->container), true);
9 |
10 | // create container for options area
11 | self->options_container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
12 | gtk_widget_set_name(GTK_WIDGET(self->options_container), "container");
13 | gtk_widget_set_vexpand(GTK_WIDGET(self->options_container), true);
14 |
15 | // create title box [icon label]
16 | self->title_container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
17 | gtk_widget_set_name(GTK_WIDGET(self->title_container), "title-container");
18 |
19 | // create icon area in title box
20 | self->title_icon_container =
21 | GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
22 | gtk_widget_set_name(GTK_WIDGET(self->title_icon_container),
23 | "icon-container");
24 | self->icon = GTK_IMAGE(gtk_image_new_from_icon_name(""));
25 | gtk_image_set_pixel_size(self->icon, 24);
26 |
27 | // append icon to title box and add label adjacent.
28 | gtk_box_append(self->title_icon_container, GTK_WIDGET(self->icon));
29 | gtk_box_append(self->title_container,
30 | GTK_WIDGET(self->title_icon_container));
31 | self->title = GTK_LABEL(gtk_label_new(""));
32 | gtk_box_append(self->title_container, GTK_WIDGET(self->title));
33 |
34 | // create banner revealer
35 | self->banner = GTK_REVEALER(gtk_revealer_new());
36 | gtk_widget_set_name(GTK_WIDGET(self->banner), "banner");
37 | gtk_revealer_set_transition_type(self->banner,
38 | GTK_REVEALER_TRANSITION_TYPE_SWING_DOWN);
39 | gtk_revealer_set_transition_duration(self->banner, 400);
40 |
41 | // create button container
42 | self->options = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
43 | gtk_widget_set_name(GTK_WIDGET(self->options), "options-container");
44 |
45 | // wire it up
46 | gtk_box_append(self->container, GTK_WIDGET(self->options_container));
47 | gtk_box_append(self->options_container, GTK_WIDGET(self->title_container));
48 | gtk_box_append(self->options_container, GTK_WIDGET(self->banner));
49 | if (scrolling) {
50 | self->scroll = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
51 | gtk_widget_set_vexpand(GTK_WIDGET(self->scroll), true);
52 | gtk_scrolled_window_set_child(self->scroll, GTK_WIDGET(self->options));
53 | gtk_scrolled_window_set_policy(self->scroll, GTK_POLICY_NEVER,
54 | GTK_POLICY_AUTOMATIC);
55 | gtk_box_append(self->options_container, GTK_WIDGET(self->scroll));
56 | } else
57 | gtk_box_append(self->options_container, GTK_WIDGET(self->options));
58 | }
59 |
60 | void quick_settings_menu_widget_set_title(QuickSettingsMenuWidget *self,
61 | const char *title) {
62 | gtk_label_set_text(GTK_LABEL(self->title), title);
63 | }
64 |
65 | void quick_settings_menu_widget_set_icon(QuickSettingsMenuWidget *self,
66 | const char *icon_name) {
67 | gtk_image_set_from_icon_name(self->icon, icon_name);
68 | }
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_menu_widget.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // QuickSettingsMenuWidget is a widget which defines the layout and sets the
4 | // appropriate CSS such that all menus in the QuickSettings uses the same
5 | // styling and layout.
6 | //
7 | // A GObject or another struct can embed this structure and initialize it.
8 | // The GObject or other structure is then fre populate 'buttons_container' box
9 | // with the selectable options in the menu.
10 | typedef struct _QuickSettingsMenuWidget {
11 | // main container for the widget
12 | // css id: "#quick-settings-menu"
13 | GtkBox *container;
14 | // sub-container which holds a the title and list of options
15 | // css id: "#quick-settings-menu #options-container"
16 | GtkBox *options_container;
17 | // title box with an icon and a title
18 | // css id: "#quick-settings-menu #options-container #options-title"
19 | GtkBox *title_container;
20 | GtkLabel *title;
21 | // A banner which can be revealed under the title.
22 | GtkRevealer *banner;
23 | // container that icon in title sits in
24 | // css id: "#quick-settings-menu #options-container #options-title
25 | // #icon-container"
26 | GtkBox *title_icon_container;
27 | // icon in container
28 | GtkImage *icon;
29 | // a vertical list of options within the menu.
30 | // css id: "#quick-settings-menu #options-container #options"
31 | GtkBox *options;
32 | // if 'scrolling' is set to true then the 'options' box will be wrapped
33 | // inside a scrolling window.
34 | GtkScrolledWindow *scroll;
35 |
36 | } QuickSettingsMenuWidget;
37 |
38 | void quick_settings_menu_widget_init(QuickSettingsMenuWidget *self,
39 | gboolean scrolling);
40 |
41 | void quick_settings_menu_widget_set_title(QuickSettingsMenuWidget *self,
42 | const char *title);
43 |
44 | void quick_settings_menu_widget_set_icon(QuickSettingsMenuWidget *self,
45 | const char *icon_name);
46 |
47 |
--------------------------------------------------------------------------------
/src/panel/quick_settings/quick_settings_scales/quick_settings_scales.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _QuickSettingsScales;
6 | #define QUICK_SETTINGS_SCALES_TYPE quick_settings_scales_get_type()
7 | G_DECLARE_FINAL_TYPE(QuickSettingsScales, quick_settings_scales, QUICK_SETTINGS,
8 | SCALES, GObject);
9 |
10 | G_END_DECLS
11 |
12 | void quick_settings_scales_reinitialize(QuickSettingsScales *self);
13 |
14 | GtkWidget *quick_settings_scales_get_widget(QuickSettingsScales *self);
15 |
16 | void quick_settings_scales_disable_audio_scales(
17 | QuickSettingsScales *self, gboolean disable);
--------------------------------------------------------------------------------
/src/rename_switcher/rename_switcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _RenameSwitcher;
8 | #define RENAME_SWITCHER_TYPE rename_switcher_get_type()
9 | G_DECLARE_FINAL_TYPE(RenameSwitcher, rename_switcher, Rename, Switcher,
10 | GObject);
11 |
12 | G_END_DECLS
13 |
14 | void rename_switcher_activate(AdwApplication *app, gpointer user_data);
15 |
16 | RenameSwitcher *rename_switcher_get_global();
17 |
18 | void rename_switcher_show(RenameSwitcher *self);
19 |
20 | void rename_switcher_hide(RenameSwitcher *self);
21 |
22 | void rename_switcher_toggle(RenameSwitcher *self);
23 |
24 |
--------------------------------------------------------------------------------
/src/services/brightness_service/brightness_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | struct _BrightnessService;
8 | #define BRIGHTNESS_SERVICE_TYPE brightness_service_get_type()
9 | G_DECLARE_FINAL_TYPE(BrightnessService, brightness_service, BRIGHTNESS, SERVICE,
10 | GObject);
11 |
12 | G_END_DECLS
13 |
14 | int brightness_service_global_init(void);
15 |
16 | // Get the global brightness service
17 | // Will return NULL if `brightness_service_global_init` has not been called.
18 | BrightnessService *brightness_service_get_global();
19 |
20 | void brightness_service_backlight_up(BrightnessService *self);
21 |
22 | void brightness_service_backlight_down(BrightnessService *self);
23 |
24 | void brightness_service_set_backlight(BrightnessService *self, float percent);
25 |
26 | float brightness_service_get_backlight(BrightnessService *self);
27 |
28 | void brightness_service_keyboard_up(BrightnessService *self);
29 |
30 | void brightness_service_keyboard_down(BrightnessService *self);
31 |
32 | void brightness_service_set_keyboard(BrightnessService *self, uint32_t value);
33 |
34 | guint32 brightness_service_get_keyboard(BrightnessService *self);
35 |
36 | guint32 brightness_service_get_keyboard_max(BrightnessService *self);
37 |
38 | gchar *brightness_service_map_icon(BrightnessService *self);
39 |
40 | gboolean brightness_service_has_backlight_brightness(BrightnessService *self);
41 |
42 | gboolean brightness_service_has_keyboard_brightness(BrightnessService *self);
43 |
--------------------------------------------------------------------------------
/src/services/clock_service.c:
--------------------------------------------------------------------------------
1 | #include "clock_service.h"
2 |
3 | #include
4 |
5 | static ClockService *global = NULL;
6 |
7 | enum signals { tick, signals_n };
8 |
9 | struct _ClockService {
10 | GObject parent_instance;
11 | gboolean enabled;
12 | };
13 | static guint signals[signals_n] = {0};
14 | G_DEFINE_TYPE(ClockService, clock_service, G_TYPE_OBJECT);
15 |
16 | // stub out dispose, finalize, class_init, and init methods
17 | static void clock_service_dispose(GObject *gobject) {
18 | ClockService *self = CLOCK_SERVICE(gobject);
19 |
20 | // Chain-up
21 | G_OBJECT_CLASS(clock_service_parent_class)->dispose(gobject);
22 | };
23 |
24 | static void clock_service_finalize(GObject *gobject) {
25 | // Chain-up
26 | G_OBJECT_CLASS(clock_service_parent_class)->finalize(gobject);
27 | };
28 |
29 | static void clock_service_class_init(ClockServiceClass *klass) {
30 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
31 | object_class->dispose = clock_service_dispose;
32 | object_class->finalize = clock_service_finalize;
33 |
34 | // create a signal which has a GDateTime as a argument
35 | signals[tick] = g_signal_new("tick", G_TYPE_FROM_CLASS(object_class),
36 | G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
37 | G_TYPE_NONE, 1, G_TYPE_DATE_TIME);
38 | };
39 |
40 | static gboolean emit_tick(gpointer self) {
41 | GDateTime *now = g_date_time_new_now_local();
42 | g_debug("clock_service.c:emit_tick() emitting signal.");
43 | g_signal_emit(self, signals[tick], 0, now);
44 | g_date_time_unref(now);
45 | return CLOCK_SERVICE(self)->enabled;
46 | }
47 |
48 | // syncs the click to the first minute boundary.
49 | static gboolean tick_sync(gpointer self) {
50 | GDateTime *now = g_date_time_new_now_local();
51 | if (g_date_time_get_second(now) != 0) {
52 | g_date_time_unref(now);
53 | return CLOCK_SERVICE(self)->enabled;
54 | }
55 | g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, 60, emit_tick, self, NULL);
56 | g_debug("clock_service.c:tick_sync() synchronized on minute boundary");
57 | return false;
58 | }
59 |
60 | static void clock_service_init(ClockService *self){
61 | self->enabled = TRUE;
62 | emit_tick(self);
63 | g_timeout_add(500, tick_sync, self);
64 | };
65 |
66 | int clock_service_global_init(void) {
67 | global = g_object_new(CLOCK_SERVICE_TYPE, NULL);
68 | return 0;
69 | }
70 |
71 | ClockService *clock_service_get_global() {
72 | return global;
73 | }
--------------------------------------------------------------------------------
/src/services/clock_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | // Simple clock service which emits a 'tick' signal on every minute.
8 | // The clock is synchronized to the next minute boundary following its
9 | // construction.
10 | //
11 | // `tick` event provides a GDateTime as its first argument.
12 | struct _ClockService;
13 | #define CLOCK_SERVICE_TYPE clock_service_get_type()
14 | G_DECLARE_FINAL_TYPE(ClockService, clock_service, CLOCK, SERVICE, GObject);
15 |
16 | G_END_DECLS
17 |
18 | int clock_service_global_init(void);
19 |
20 | // Get the global clock service
21 | // Will return NULL if `clock_service_global_init` has not been called.
22 | ClockService *clock_service_get_global();
23 |
24 | gboolean clock_service_get_enabled(ClockService *self);
25 |
26 | // Once a clock service is disabled you can discard it.
27 | // Create a new clock service if you need an enabled clock tick.
28 | gboolean clock_service_set_enabled(ClockService *self, gboolean enabled);
--------------------------------------------------------------------------------
/src/services/dbus_service.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | typedef struct _DBUS {
4 | GDBusConnection *system;
5 | GDBusConnection *session;
6 | } DBUS;
7 |
8 | G_BEGIN_DECLS
9 |
10 | struct _DBUSService;
11 | #define DBUS_SERVICE_TYPE dbus_service_get_type()
12 | G_DECLARE_FINAL_TYPE(DBUSService, dbus_service, DBUS, SERVICE, GObject);
13 |
14 | G_END_DECLS
15 |
16 | int dbus_service_global_init(void);
17 |
18 | DBUSService *dbus_service_get_global();
19 |
20 | GDBusConnection *dbus_service_get_system_bus(DBUSService *self);
21 |
22 | GDBusConnection *dbus_service_get_session_bus(DBUSService *self);
23 |
24 | GHashTable *dbus_service_get_bus_names(DBUSService *self, gboolean system);
25 |
--------------------------------------------------------------------------------
/src/services/ipc_service/ipc_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | // A IPC Service which directly interfaces with the `way-sh` CLI.
8 | //
9 | // The service talks over a DGRAM Unix socket located at
10 | // $XDG_RUNTIME_DIR/way-shell.sock
11 | struct _IPCService;
12 | #define IPC_SERVICE_TYPE ipc_service_get_type()
13 | G_DECLARE_FINAL_TYPE(IPCService, ipc_service, IPC, SERVICE, GObject);
14 |
15 | G_END_DECLS
16 |
17 | int ipc_service_global_init(void);
18 |
19 | // Get the global ipc service
20 | // Will return NULL if `ipc_service_global_init` has not been called.
21 | IPCService *ipc_service_get_global();
22 |
--------------------------------------------------------------------------------
/src/services/logind_service/logind_service.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _LogindService;
6 | #define LOGIND_SERVICE_TYPE logind_service_get_type()
7 | G_DECLARE_FINAL_TYPE(LogindService, logind_service, LOGIND, SERVICE, GObject);
8 |
9 | G_END_DECLS
10 |
11 | int logind_service_global_init(void);
12 |
13 | LogindService *logind_service_get_global();
14 |
15 | gboolean logind_service_can_reboot(LogindService *self);
16 |
17 | void logind_service_reboot(LogindService *self);
18 |
19 | gboolean logind_service_can_power_off(LogindService *self);
20 |
21 | void logind_service_power_off(LogindService *self);
22 |
23 | gboolean logind_service_can_suspend(LogindService *self);
24 |
25 | void logind_service_suspend(LogindService *self);
26 |
27 | gboolean logind_service_can_hibernate(LogindService *self);
28 |
29 | void logind_service_hibernate(LogindService *self);
30 |
31 | gboolean logind_service_can_hybrid_sleep(LogindService *self);
32 |
33 | void logind_service_hybrid_sleep(LogindService *self);
34 |
35 | gboolean logind_service_can_suspendthenhibernate(LogindService *self);
36 |
37 | void logind_service_suspendthenhibernate(LogindService *self);
38 |
39 | void logind_service_kill_session(LogindService *self);
40 |
41 | int logind_service_session_set_brightness(LogindService *self,
42 | const gchar *arg_subsystem,
43 | const gchar *arg_name,
44 | guint arg_brightness);
45 |
46 | gboolean logind_service_set_idle_inhibit(LogindService *self, gboolean enable);
47 |
48 | gboolean logind_service_get_idle_inhibit(LogindService *self);
--------------------------------------------------------------------------------
/src/services/media_player_service/media_player_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "media_player_dbus.h"
6 |
7 | typedef struct _MediaPlayer {
8 | DbusMediaPlayer2Player *player;
9 | DbusMediaPlayer2 *proxy;
10 | gchar *identity;
11 | gchar *name;
12 | gchar *playback_status;
13 | gchar *art_url;
14 | gchar *album;
15 | gchar *artist;
16 | gchar *title;
17 | } MediaPlayer;
18 |
19 | G_BEGIN_DECLS
20 |
21 | struct _MediaPlayerService;
22 | #define MEDIA_PLAYER_SERVICE_TYPE media_player_service_get_type()
23 | G_DECLARE_FINAL_TYPE(MediaPlayerService, media_player_service, MEDIA_PLAYER,
24 | SERVICE, GObject);
25 |
26 | G_END_DECLS
27 |
28 | int media_player_service_global_init(void);
29 |
30 | MediaPlayerService *media_player_service_get_global();
31 |
32 | // player API, all API calls just require a unique MediaPlayer name.
33 | // this name matches the unique name on DBUS for the service providing
34 | // the /org/mpris/MediaPlayer2 instance.
35 | void media_player_service_player_play(MediaPlayerService *self, gchar *name);
36 |
37 | void media_player_service_player_pause(MediaPlayerService *self, gchar *name);
38 |
39 | void media_player_service_player_playpause(MediaPlayerService *self,
40 | gchar *name);
41 |
42 | void media_player_service_player_stop(MediaPlayerService *self, gchar *name);
43 |
44 | void media_player_service_player_next(MediaPlayerService *self, gchar *name);
45 |
46 | void media_player_service_player_previous(MediaPlayerService *self,
47 | gchar *name);
48 |
49 | void media_player_service_player_raise(MediaPlayerService *self, gchar *name);
50 |
--------------------------------------------------------------------------------
/src/services/network_manager_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "nm-core-types.h"
7 |
8 | G_BEGIN_DECLS
9 |
10 | // Simple clock service which emits a 'tick' signal on every minute.
11 | // The clock is synchronized to the next minute boundary following its
12 | // construction.
13 | //
14 | // `tick` event provides a GDateTime as its first argument.
15 | struct _NetworkManagerService;
16 | #define NETWORK_MANAGER_SERVICE_TYPE network_manager_service_get_type()
17 | G_DECLARE_FINAL_TYPE(NetworkManagerService, network_manager_service,
18 | NETWORK_MANAGER, SERVICE, GObject);
19 |
20 | G_END_DECLS
21 |
22 | int network_manager_service_global_init(void);
23 |
24 | // Get the global clock service
25 | // Will return NULL if `network_manager_service_global_init` has not been
26 | // called.
27 | NetworkManagerService *network_manager_service_get_global();
28 |
29 | const GPtrArray *network_manager_service_get_devices(
30 | NetworkManagerService *self);
31 |
32 | gboolean network_manager_service_wifi_available(NetworkManagerService *self);
33 |
34 | gboolean network_manager_service_ethernet_available(
35 | NetworkManagerService *self);
36 |
37 | NMState network_manager_service_get_state(NetworkManagerService *self);
38 |
39 | // A simplification of Device state which returns
40 | // NM_DEVICE_STATE_UNKNOWN if there are no wifi devices on the system
41 | // NM_DEVICE_STATE_DISCONNECTED if all wifi devices are disconnected
42 | // NM_DEVICE_STATE_PREPARE if at least one wifi device is activating
43 | // NM_DEVICE_STATE_ACTIVATED if at least one wifi device is activate
44 | NMDeviceState network_manager_service_wifi_state(NetworkManagerService *self);
45 |
46 | NMDevice *network_manager_service_get_primary_device(
47 | NetworkManagerService *self);
48 |
49 | char *network_manager_service_ap_strength_to_icon_name(guchar strength);
50 |
51 | char *network_manager_service_ap_to_name(NMAccessPoint *ap);
52 |
53 | void network_manager_service_ap_join(NetworkManagerService *self,
54 | NMDeviceWifi *dev, NMAccessPoint *ap,
55 | const char *password);
56 |
57 | void network_manager_service_ap_disconnect(NetworkManagerService *self,
58 | NMDeviceWifi *dev);
59 |
60 | void network_manager_service_wireless_enable(NetworkManagerService *self,
61 | gboolean enabled);
62 |
63 | void network_manager_service_networking_enable(NetworkManagerService *self,
64 | gboolean enabled);
65 |
66 | gboolean network_manager_has_vpn(NetworkManagerService *self);
67 |
68 | GHashTable *network_manager_get_vpn_connections(NetworkManagerService *self);
69 |
70 | NMVpnConnection *network_manager_get_active_vpn_connection(
71 | NetworkManagerService *self);
72 |
73 | void network_manager_activate_vpn(NetworkManagerService *self, const gchar *id,
74 | gboolean activate);
75 |
76 | gboolean network_manager_service_get_networking_enabled(
77 | NetworkManagerService *self);
78 |
79 | GHashTable *network_manager_service_get_active_vpn_connections(
80 | NetworkManagerService *self);
81 |
--------------------------------------------------------------------------------
/src/services/notifications_service/notifications_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | G_BEGIN_DECLS
6 |
7 | // A Service which acts as a org.freedesktop.Notification daemon.
8 | //
9 | // Listens on DBUS for notifications and provides an API for acting upon them.
10 | struct _NotificationsService;
11 | #define NOTIFICATIONS_SERVICE_TYPE notifications_service_get_type()
12 | G_DECLARE_FINAL_TYPE(NotificationsService, notifications_service, NOTIFICATIONS,
13 | SERVICE, GObject);
14 |
15 | G_END_DECLS
16 |
17 | enum NotifcationsClosedReason {
18 | NOTIFICATIONS_CLOSED_REASON_EXPIRED = 1,
19 | NOTIFICATIONS_CLOSED_REASON_DISMISSED = 2,
20 | NOTIFICATIONS_CLOSED_REASON_REQUESTED = 3,
21 | NOTIFICATIONS_CLOSED_REASON_UNDEFINED = 4,
22 | };
23 |
24 | typedef struct _NotificationImageData {
25 | // width (i): Width of image in pixels
26 | // height (i): Height of image in pixels
27 | // rowstride (i): Distance in bytes between row starts
28 | // has_alpha (b): Whether the image has an alpha channel
29 | // bits_per_sample (i): Must always be 8
30 | // channels (i): If has_alpha is TRUE, must be 4, otherwise 3
31 | // data (ay): The image data, in RGB byte order
32 | uint32_t width;
33 | uint32_t height;
34 | uint32_t rowstride;
35 | gboolean has_alpha;
36 | uint32_t bits_per_sample;
37 | uint32_t channels;
38 | char *data;
39 | } NotificationImageData;
40 |
41 | // org.freedesktop.Notification structure
42 | typedef struct _Notification {
43 | char *app_name;
44 | char *app_icon;
45 | char *summary;
46 | char *body;
47 | char **actions;
48 | GVariant *hints;
49 | char *category;
50 | char *desktop_entry;
51 | char *image_path;
52 | NotificationImageData img_data;
53 | int32_t id;
54 | uint32_t replaces_id;
55 | int32_t expire_timeout;
56 | gboolean action_icons;
57 | gboolean resident;
58 | gboolean transient;
59 | uint8_t urgency;
60 | // way-shell fields
61 | // is_internal informs way-shell this is a notification created by way-shell
62 | // itself. app_icon will take the form of an icon_name in the default icon
63 | // theme.
64 | gboolean is_internal;
65 | GDateTime *created_on;
66 | } Notification;
67 |
68 | int notifications_service_global_init();
69 |
70 | NotificationsService *notifications_service_get_global();
71 |
72 | int notifications_service_closed_notification(
73 | NotificationsService *self, guint32 id,
74 | enum NotifcationsClosedReason reason);
75 |
76 | int notifications_service_invoke_action(NotificationsService *self, guint32 id,
77 | char *action_key);
78 |
79 | GPtrArray *notifications_service_get_notifications(NotificationsService *self);
80 |
81 | // Internal notifications API which can be used by Way-Shell.
82 | // Actions currently not supported, fill in n->app_icon with a themed icon name
83 | // to set the icon to a specific icon.
84 | void notifications_service_send_notification(NotificationsService *self, Notification *n);
85 |
--------------------------------------------------------------------------------
/src/services/power_profiles_service/power_profiles_service.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | G_BEGIN_DECLS
4 |
5 | struct _PowerProfilesService;
6 | #define POWER_PROFILES_SERVICE_TYPE power_profiles_service_get_type()
7 | G_DECLARE_FINAL_TYPE(PowerProfilesService, power_profiles_service,
8 | POWER_PROFILES, SERVICE, GObject);
9 |
10 | G_END_DECLS
11 |
12 | int power_profiles_service_global_init(void);
13 |
14 | PowerProfilesService *power_profiles_service_get_global();
15 |
16 | GArray *power_profiles_service_get_profiles(PowerProfilesService *self);
17 |
18 | void power_profiles_service_set_profile(PowerProfilesService *self,
19 | gchar *profile);
20 |
21 | const gchar *power_profiles_service_get_active_profile(
22 | PowerProfilesService *self);
23 |
24 | const char *power_profiles_service_profile_to_icon(const char *profile);
25 |
--------------------------------------------------------------------------------
/src/services/status_notifier_service/libdbusmenu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "status_notifier_service.h"
6 |
7 | void libdbusmenu_parse_layout(GVariant *layout, GMenuItem *parent_menu_item,
8 | StatusNotifierItem *item);
9 |
--------------------------------------------------------------------------------
/src/services/status_notifier_service/status_notifier_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "dbusmenu_dbus.h"
6 | #include "status_notifier_item_dbus.h"
7 |
8 | #define SNI_GACTION_PREFIX "sni"
9 | #define SNI_GRACTION_ITEM_CLICKED "sni.item-clicked"
10 | #define SNI_GRACTION_MENU_ABOUT_TO_SHOW "sni.about-to-show"
11 |
12 | typedef struct StatusNotifierItem {
13 | DbusItemV0Gen *proxy;
14 | DbusDbusmenu *menu_proxy;
15 | GActionGroup *action_group;
16 | GMenu *menu_model;
17 | gchar *bus_name;
18 | gchar *obj_name;
19 | gchar *register_service_name;
20 |
21 | // item properties
22 | gchar *category;
23 | gchar *id;
24 | gchar *title;
25 | gchar *status;
26 | guint window_id;
27 |
28 | GdkPixbuf *icon_pixmap_from_theme;
29 | gchar *icon_theme_path;
30 | gchar *icon_name;
31 | GdkPixbuf *icon_pixmap;
32 |
33 | gchar *overlay_icon_name;
34 | GdkPixbuf *overlay_icon_pixmap;
35 |
36 | gchar *attention_icon_name;
37 | GdkPixbuf *attention_icon_pixmap;
38 | gchar *attention_movie_name;
39 | } StatusNotifierItem;
40 |
41 | void status_notifier_item_about_to_show(StatusNotifierItem *self,
42 | gint32 menu_item_id);
43 |
44 | GdkPixbuf *pixbuf_from_icon_data(GVariant *icon_data);
45 | void *status_notifier_item_init(StatusNotifierItem *self, DbusItemV0Gen *proxy);
46 | const gchar *status_notifier_item_get_category(StatusNotifierItem *self);
47 | const gchar *status_notifier_item_get_id(StatusNotifierItem *self);
48 | const gchar *status_notifier_item_get_title(StatusNotifierItem *self);
49 | const gchar *status_notifier_item_get_status(StatusNotifierItem *self);
50 | const int status_notifier_item_get_window_id(StatusNotifierItem *self);
51 | const gchar *status_notifier_item_get_icon_name(StatusNotifierItem *self);
52 | GdkPixbuf *status_notifier_item_get_icon_pixmap(StatusNotifierItem *self);
53 | const gchar *status_notifier_item_get_overlay_icon_name(
54 | StatusNotifierItem *self);
55 | GdkPixbuf *status_notifier_item_get_overlay_icon_pixmap(
56 | StatusNotifierItem *self);
57 | const gchar *status_notifier_item_get_attention_icon_name(
58 | StatusNotifierItem *self);
59 | GdkPixbuf *status_notifier_item_get_attention_icon_pixmap(
60 | StatusNotifierItem *self);
61 | const gchar *status_notifier_item_get_attention_movie_name(
62 | StatusNotifierItem *self);
63 | // TODO: get_tooltip
64 | const gboolean status_notifier_item_get_item_is_menu(StatusNotifierItem *self);
65 | const gchar *status_notifier_item_get_menu(StatusNotifierItem *self);
66 | DbusItemV0Gen *status_notifier_item_get_proxy(StatusNotifierItem *self);
67 | void status_notifier_item_free(StatusNotifierItem *self);
68 |
69 | G_BEGIN_DECLS
70 |
71 | // A Service which acts as a org.freedesktop.Notification daemon.
72 | //
73 | // Listens on DBUS for notifications and provides an API for acting upon
74 | // them.
75 | struct _StatusNotifierService;
76 | #define NOTIFICATIONS_SERVICE_TYPE status_notifier_service_get_type()
77 | G_DECLARE_FINAL_TYPE(StatusNotifierService, status_notifier_service,
78 | STATUS_NOTIFIER, SERVICE, GObject);
79 |
80 | G_END_DECLS
81 |
82 | int status_notifier_service_global_init();
83 |
84 | GHashTable *status_notifier_service_get_items(StatusNotifierService *self);
85 |
86 | StatusNotifierService *status_notifier_service_get_global();
87 |
--------------------------------------------------------------------------------
/src/services/theme_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | enum ThemeServiceTheme { THEME_LIGHT, THEME_DARK };
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _ThemeService;
10 | #define THEME_SERVICE_TYPE theme_service_get_type()
11 | G_DECLARE_FINAL_TYPE(ThemeService, theme_service, THEME, SERVICE, GObject);
12 |
13 | G_END_DECLS
14 |
15 | int theme_service_global_init(void);
16 |
17 | ThemeService *theme_service_get_global();
18 |
19 | void theme_service_set_light_theme(ThemeService *self, gboolean light_theme);
20 |
21 | void theme_service_set_dark_theme(ThemeService *self, gboolean dark_theme);
22 |
23 | enum ThemeServiceTheme theme_service_get_theme(ThemeService *self);
24 |
--------------------------------------------------------------------------------
/src/services/upower_service.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | // Service which provides power state information for various devices.
9 | // Backend is provided by UPower daemon.
10 | struct _UPowerService;
11 | #define UPOWER_SERVICE_TYPE upower_service_get_type()
12 | G_DECLARE_FINAL_TYPE(UPowerService, upower_service, UPOWER, SERVICE, GObject);
13 |
14 | G_END_DECLS
15 |
16 | int upower_service_global_init(void);
17 |
18 | UpClient *upower_service_get_up_client(UPowerService *self);
19 |
20 | // Get the global upower service
21 | // Will return NULL if `clock_service_global_init` has not been called.
22 | UPowerService *upower_service_get_global();
23 |
24 | // Returns the primary power source for the system.
25 | // If a battery is present this will be the first battery on the system.
26 | // If no battery is present this will be the AC line power device.
27 | UpDevice *upower_service_get_primary_device(UPowerService *self);
28 |
29 | // Returns whether the primary device is a battery or an AC device.
30 | gboolean upower_service_primary_is_bat(UPowerService *self);
31 |
32 | // Returns our application's preferred icon to represent the state of the
33 | // UpDevice.
34 | char *upower_device_map_icon_name(UpDevice *device);
--------------------------------------------------------------------------------
/src/services/wayland/core.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | // expose WaylandCoreService's signals in our header so we can allow invoking
8 | // signals from global listener handlers in separate files. See: wl_output.c for
9 | // an example.
10 | enum wl_signals { wl_output_added, wl_output_removed, wl_signals_n };
11 |
12 | extern guint wayland_core_service_signals[wl_signals_n];
13 |
14 | enum WaylandType {
15 | WL_REGISTRY,
16 | WL_SEAT,
17 | WL_OUTPUT,
18 | WLR_FOREIGN_TOPLEVEL,
19 | WLR_GAMMA_CONTROL
20 | };
21 |
22 | typedef struct _WaylandHeader {
23 | enum WaylandType type;
24 | } WaylandHeader;
25 |
26 | typedef struct WaylandSeat {
27 | WaylandHeader header;
28 | struct wl_seat *seat;
29 | char *name;
30 | } WaylandSeat;
31 |
32 | typedef struct _WaylandOutput {
33 | WaylandHeader header;
34 | struct wl_output *output;
35 | GdkMonitor *monitor;
36 | char *name;
37 | char *desc;
38 | char *make;
39 | char *model;
40 | gboolean initialized;
41 | } WaylandOutput;
42 |
43 | G_BEGIN_DECLS
44 |
45 | // The WaylandCoreService implements the core Wayland interface.
46 | //
47 | // This includes inventorying useful core wayland protocol objects along with
48 | // instantiating useful services if the global managers and protocols are
49 | // available.
50 | //
51 | // As a separation of concerns, WaylandCoreService is responsible for binding to
52 | // useful globals, at which point the bound interface is then handed to any
53 | // instantiated service which implements the interface's functionality.
54 | //
55 | // In practice, this means the WaylandCoreService inventories and signals when
56 | // https://wayland.app/protocols/wayland objects are added or removed.
57 | //
58 | // Additionally, it will query the inventory for useful globals and construct
59 | // Way-Shell services for these globals. For instance, if WaylandCoreService
60 | // discovers that `zwlr_gamma_control_manager_v1` is available it will construct
61 | // a WaylandGammaControlService and this service's API can be used to implement
62 | // a 'nightlight' feature.
63 | //
64 | // Operationally, this service's initialization blocks the main thread until an
65 | // initial sync with the Wayland server, guaranteeing that all other Wayland
66 | // related services are instantiated by the time the core service's
67 | // instantiation returns.
68 | struct _WaylandCoreService;
69 | #define WAYLAND_CORE_SERVICE_TYPE wayland_core_service_get_type()
70 | G_DECLARE_FINAL_TYPE(WaylandCoreService, wayland_core_service, WAYLAND,
71 | CORE_SERVICE, GObject);
72 |
73 | G_END_DECLS
74 |
75 | int wayland_core_service_global_init(void);
76 |
77 | WaylandCoreService *wayland_core_service_get_global();
78 |
79 | GHashTable *wayland_core_service_get_globals(WaylandCoreService *self);
80 |
81 | GHashTable *wayland_core_service_get_seats(WaylandCoreService *self);
82 |
83 | GHashTable *wayland_core_service_get_outputs(WaylandCoreService *self);
84 |
85 | struct wl_display *wayland_core_service_get_display(WaylandCoreService *self);
86 |
--------------------------------------------------------------------------------
/src/services/wayland/foreign_toplevel_service/foreign_toplevel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../core.h"
6 | #include "../wlr-foreign-toplevel-management-unstable-v1.h"
7 |
8 | enum WaylandWLRForeignTopLevelState {
9 | TOPLEVEL_STATE_MAXIMIZED,
10 | TOPLEVEL_STATE_MINIMIZED,
11 | TOPLEVEL_STATE_ACTIVATED,
12 | TOPLEVEL_STATE_FULLSCEEN,
13 | };
14 |
15 | typedef struct _WaylandWLRForeignTopLevel {
16 | WaylandHeader header;
17 | struct zwlr_foreign_toplevel_handle_v1 *toplevel;
18 | char *app_id;
19 | char *title;
20 | gboolean entered;
21 | gboolean activated;
22 | gboolean closed;
23 | enum WaylandWLRForeignTopLevelState state;
24 |
25 | } WaylandWLRForeignTopLevel;
26 |
27 | G_BEGIN_DECLS
28 |
29 | struct _WaylandForeignToplevelService;
30 | #define WAYLAND_FOREIGN_TOPLEVEL_SERVICE_TYPE \
31 | wayland_foreign_toplevel_service_get_type()
32 | G_DECLARE_FINAL_TYPE(WaylandForeignToplevelService,
33 | wayland_foreign_toplevel_service, WAYLAND,
34 | FOREIGN_TOPLEVEL_SERVICE, GObject);
35 |
36 | G_END_DECLS
37 |
38 | int wayland_foreign_toplevel_service_global_init(
39 | WaylandCoreService *core, struct zwlr_foreign_toplevel_manager_v1 *mgr);
40 |
41 | WaylandForeignToplevelService *wayland_foreign_toplevel_service_get_global();
42 |
43 | GHashTable *wayland_foreign_toplevel_service_get_toplevels(
44 | WaylandForeignToplevelService *self);
45 |
46 | void wayland_foreign_toplevel_service_activate(
47 | WaylandForeignToplevelService *self, WaylandWLRForeignTopLevel *toplevel);
48 |
49 | void wayland_foreign_toplevel_service_close(
50 | WaylandForeignToplevelService *self, WaylandWLRForeignTopLevel *toplevel);
51 |
52 | void wayland_foreign_toplevel_service_maximize(
53 | WaylandForeignToplevelService *self, WaylandWLRForeignTopLevel *toplevel);
54 |
--------------------------------------------------------------------------------
/src/services/wayland/gamma_control_service/gamma.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../core.h"
6 | #include "../wlr-gamma-control-unstable-v1.h"
7 |
8 | typedef struct _WaylandWLRGammaControl {
9 | WaylandHeader header;
10 | struct zwlr_gamma_control_v1 *control;
11 | WaylandOutput *output;
12 | uint32_t gamma_size;
13 | int gamma_table_fd;
14 | int temperature;
15 | } WaylandWLRGammaControl;
16 |
17 | G_BEGIN_DECLS
18 |
19 | struct _WaylandGammaControlService;
20 | #define WAYLAND_GAMMA_CONTROL_SERVICE_TYPE \
21 | wayland_gamma_control_service_get_type()
22 | G_DECLARE_FINAL_TYPE(WaylandGammaControlService, wayland_gamma_control_service,
23 | WAYLAND, GAMMA_CONTROL_SERVICE, GObject);
24 |
25 | G_END_DECLS
26 |
27 | int wayland_gamma_control_service_global_init(
28 | WaylandCoreService *core, struct zwlr_gamma_control_manager_v1 *mgr);
29 |
30 | WaylandGammaControlService *wayland_gamma_control_service_get_global();
31 |
32 | void wayland_gamma_control_service_set_temperature(
33 | WaylandGammaControlService *self, double temperature);
34 |
35 | void wayland_gamma_control_service_destroy(WaylandGammaControlService *self);
36 |
37 | gboolean wayland_gamma_control_service_enabled(
38 | WaylandGammaControlService *self);
39 |
--------------------------------------------------------------------------------
/src/services/wayland/keyboard_shortcuts_inhibit_service/ksi.c:
--------------------------------------------------------------------------------
1 | #include "ksi.h"
2 |
3 | #include
4 |
5 | #include "../core.h"
6 |
7 | static WaylandKSIService *global = NULL;
8 |
9 | struct _WaylandKSIService {
10 | GObject parent_instance;
11 | WaylandCoreService *core;
12 | GdkToplevel *inhibitor;
13 | };
14 |
15 | G_DEFINE_TYPE(WaylandKSIService, wayland_ksi_service, G_TYPE_OBJECT);
16 |
17 | // stub out dispose, finalize, class_init, and init methods for this GObject
18 | static void wayland_ksi_service_dispose(GObject *gobject) {
19 | // Chain-up
20 | G_OBJECT_CLASS(wayland_ksi_service_parent_class)->dispose(gobject);
21 | };
22 |
23 | static void wayland_ksi_service_finalize(GObject *gobject) {
24 | // Chain-up
25 | G_OBJECT_CLASS(wayland_ksi_service_parent_class)->finalize(gobject);
26 | };
27 |
28 | static void wayland_ksi_service_class_init(WaylandKSIServiceClass *klass) {
29 | GObjectClass *object_class = G_OBJECT_CLASS(klass);
30 | object_class->dispose = wayland_ksi_service_dispose;
31 | object_class->finalize = wayland_ksi_service_finalize;
32 | };
33 |
34 | static void wayland_ksi_service_init(WaylandKSIService *self) {};
35 |
36 | int wayland_ksi_service_global_init(WaylandCoreService *core) {
37 | global = g_object_new(WAYLAND_KSI_SERVICE_TYPE, NULL);
38 | global->core = core;
39 | return 0;
40 | };
41 |
42 | WaylandKSIService *wayland_ksi_service_get_global() { return global; };
43 |
44 | gboolean wayland_ksi_inhibit(WaylandKSIService *self, GtkWidget *widget) {
45 | // its actually easier to just go through GDK as it abstracts the Wayland
46 | // bits for us.
47 | g_debug("ksi.c:wayland_ksi_inhibit: called ");
48 |
49 | if (self->inhibitor) return false;
50 |
51 | GtkNative *gdk_native = gtk_widget_get_native(widget);
52 | if (!gdk_native) {
53 | g_critical(
54 | "ksi.c:wayland_ksi_inhibit: "
55 | "failed to get native widget");
56 | return false;
57 | }
58 |
59 | GdkSurface *gdk_surface = gtk_native_get_surface(gdk_native);
60 | if (!gdk_surface) {
61 | g_critical(
62 | "ksi.c:wayland_ksi_inhibit: "
63 | "failed to get GDK surface");
64 | return false;
65 | }
66 |
67 | if (!GDK_IS_TOPLEVEL(gdk_surface)) {
68 | g_critical(
69 | "ksi.c:wayland_ksi_inhibit: "
70 | "widget is not a GDK toplevel");
71 | return false;
72 | }
73 |
74 | g_debug(
75 | "ksi.c:wayland_ksi_inhibit(): "
76 | "inhibiting system shortcuts");
77 |
78 | GdkToplevel *toplevel = GDK_TOPLEVEL(gdk_surface);
79 | gdk_toplevel_inhibit_system_shortcuts(toplevel, NULL);
80 | self->inhibitor = toplevel;
81 | return true;
82 | }
83 |
84 | gboolean wayland_ksi_inhibit_destroy(WaylandKSIService *self) {
85 | if (!self->inhibitor) return false;
86 | gdk_toplevel_restore_system_shortcuts(self->inhibitor);
87 | self->inhibitor = NULL;
88 | return true;
89 | }
90 |
--------------------------------------------------------------------------------
/src/services/wayland/keyboard_shortcuts_inhibit_service/ksi.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../core.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | // The WaylandKSIService can be used to black Wayland's registered keyboard
10 | // shortcuts and forward them to the GdkToplevel provided to its API.
11 | //
12 | // A GdkToplevel is the top-most GdkWidget, which is usually the Gdk/AdwWindow
13 | // widget.
14 | //
15 | // For simplicity, only a single GdkToplevel can own the inhibitor at a time.
16 | // This maybe expanded if the need for multiple GdkToplevels to own the
17 | // inhibitor arises.
18 | struct _WaylandKSIService;
19 | #define WAYLAND_KSI_SERVICE_TYPE wayland_ksi_service_get_type()
20 | G_DECLARE_FINAL_TYPE(WaylandKSIService, wayland_ksi_service, WAYLAND,
21 | KSI_SERVICE, GObject);
22 |
23 | G_END_DECLS
24 |
25 | int wayland_ksi_service_global_init(WaylandCoreService *core);
26 |
27 | WaylandKSIService *wayland_ksi_service_get_global();
28 |
29 | // Make compositor forward all key events to `widget`.
30 | // `widget` must be a GdkToplevel.
31 | gboolean wayland_ksi_inhibit(WaylandKSIService *self, GtkWidget *widget);
32 |
33 | // Destroy the key events inhibitor, if it exists.
34 | gboolean wayland_ksi_inhibit_destroy(WaylandKSIService *self);
35 |
--------------------------------------------------------------------------------
/src/services/wayland/wl_output.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "core.h"
4 |
5 | void wl_output_register(WaylandCoreService *self, struct wl_output *wl_output, uint32_t name);
6 |
7 | void wl_output_remove(WaylandCoreService *self, WaylandOutput *output);
8 |
--------------------------------------------------------------------------------
/src/services/wayland/wl_seat.c:
--------------------------------------------------------------------------------
1 | #include "wl_seat.h"
2 |
3 | #include
4 |
5 | #define WAYLAND_SEAT(wl_seat) \
6 | self = (WaylandCoreService *)data; \
7 | seats = wayland_core_service_get_seats(self); \
8 | seat_data = g_hash_table_lookup(seats, seat);
9 |
10 | static void wl_seat_listener_capabilities(void *data, struct wl_seat *seat,
11 | uint32_t capabilities) {
12 | g_debug("wl_seat.c:seat_listener_capabilities(): capabilities: %d",
13 | capabilities);
14 | // no-op, we don't care about capabilities
15 | }
16 |
17 | static void wl_seat_listener_name(void *data, struct wl_seat *seat,
18 | const char *name) {
19 | g_debug("wl_seat.c:seat_listener_name(): name: %s", name);
20 |
21 | WaylandCoreService *self;
22 | GHashTable *seats;
23 | WaylandSeat *seat_data;
24 | WAYLAND_SEAT(seat);
25 |
26 | seat_data->name = g_strdup(name);
27 |
28 | g_debug("wl_seat.c:seat_listener_name(): seat_data->name: %s",
29 | seat_data->name);
30 | }
31 |
32 | static const struct wl_seat_listener wl_seat_listener = {
33 | .capabilities = wl_seat_listener_capabilities,
34 | .name = wl_seat_listener_name,
35 | };
36 |
37 | void wl_seat_register(WaylandCoreService *self, struct wl_seat *wl_seat,
38 | uint32_t name) {
39 | GHashTable *seats = wayland_core_service_get_seats(self);
40 | GHashTable *globals = wayland_core_service_get_globals(self);
41 |
42 | WaylandSeat *seat = g_new0(WaylandSeat, 1);
43 | seat->header.type = WL_SEAT;
44 | seat->seat = wl_seat;
45 | seat->name = NULL;
46 |
47 | g_hash_table_insert(globals, GUINT_TO_POINTER(name), seat);
48 | g_hash_table_insert(seats, wl_seat, seat);
49 | wl_seat_add_listener(wl_seat, &wl_seat_listener, self);
50 | }
51 |
52 | void wl_seat_remove(WaylandCoreService *self, WaylandSeat *seat) {
53 | g_debug("wl_seat.c:wayland_seat_remove(): seat: %s", seat->name);
54 | GHashTable *seats = wayland_core_service_get_seats(self);
55 | GHashTable *globals = wayland_core_service_get_globals(self);
56 |
57 | // remove from seats hash table
58 | g_hash_table_remove(seats, seat->seat);
59 |
60 | // release seat from wayland
61 | wl_seat_release(seat->seat);
62 |
63 | // free seat
64 | g_free(seat->name);
65 | g_free(seat);
66 |
67 | g_hash_table_remove(globals, GUINT_TO_POINTER(seat->name));
68 | }
69 |
--------------------------------------------------------------------------------
/src/services/wayland/wl_seat.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "core.h"
4 |
5 | void wl_seat_register(WaylandCoreService *self, struct wl_seat *wl_seat,
6 | uint32_t name);
7 |
8 | void wl_seat_remove(WaylandCoreService *self, WaylandSeat *seat);
9 |
--------------------------------------------------------------------------------
/src/services/wayland/wlr-gamma-control-unstable-v1.c:
--------------------------------------------------------------------------------
1 | /* Generated by wayland-scanner 1.23.0 */
2 |
3 | /*
4 | * Copyright © 2015 Giulio camuffo
5 | * Copyright © 2018 Simon Ser
6 | *
7 | * Permission to use, copy, modify, distribute, and sell this
8 | * software and its documentation for any purpose is hereby granted
9 | * without fee, provided that the above copyright notice appear in
10 | * all copies and that both that copyright notice and this permission
11 | * notice appear in supporting documentation, and that the name of
12 | * the copyright holders not be used in advertising or publicity
13 | * pertaining to distribution of the software without specific,
14 | * written prior permission. The copyright holders make no
15 | * representations about the suitability of this software for any
16 | * purpose. It is provided "as is" without express or implied
17 | * warranty.
18 | *
19 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26 | * THIS SOFTWARE.
27 | */
28 |
29 | #include
30 | #include
31 | #include
32 | #include "wayland-util.h"
33 |
34 | #ifndef __has_attribute
35 | # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
36 | #endif
37 |
38 | #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
39 | #define WL_PRIVATE __attribute__ ((visibility("hidden")))
40 | #else
41 | #define WL_PRIVATE
42 | #endif
43 |
44 | extern const struct wl_interface wl_output_interface;
45 | extern const struct wl_interface zwlr_gamma_control_v1_interface;
46 |
47 | static const struct wl_interface *wlr_gamma_control_unstable_v1_types[] = {
48 | NULL,
49 | &zwlr_gamma_control_v1_interface,
50 | &wl_output_interface,
51 | };
52 |
53 | static const struct wl_message zwlr_gamma_control_manager_v1_requests[] = {
54 | { "get_gamma_control", "no", wlr_gamma_control_unstable_v1_types + 1 },
55 | { "destroy", "", wlr_gamma_control_unstable_v1_types + 0 },
56 | };
57 |
58 | WL_PRIVATE const struct wl_interface zwlr_gamma_control_manager_v1_interface = {
59 | "zwlr_gamma_control_manager_v1", 1,
60 | 2, zwlr_gamma_control_manager_v1_requests,
61 | 0, NULL,
62 | };
63 |
64 | static const struct wl_message zwlr_gamma_control_v1_requests[] = {
65 | { "set_gamma", "h", wlr_gamma_control_unstable_v1_types + 0 },
66 | { "destroy", "", wlr_gamma_control_unstable_v1_types + 0 },
67 | };
68 |
69 | static const struct wl_message zwlr_gamma_control_v1_events[] = {
70 | { "gamma_size", "u", wlr_gamma_control_unstable_v1_types + 0 },
71 | { "failed", "", wlr_gamma_control_unstable_v1_types + 0 },
72 | };
73 |
74 | WL_PRIVATE const struct wl_interface zwlr_gamma_control_v1_interface = {
75 | "zwlr_gamma_control_v1", 1,
76 | 2, zwlr_gamma_control_v1_requests,
77 | 2, zwlr_gamma_control_v1_events,
78 | };
79 |
80 |
--------------------------------------------------------------------------------
/src/services/window_manager_service/sway/ipc.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef _SWAY_IPC_H
4 | #define _SWAY_IPC_H
5 |
6 | #define event_mask(ev) (1 << (ev & 0x7F))
7 |
8 | enum ipc_command_type {
9 | // i3 command types - see i3's I3_REPLY_TYPE constants
10 | IPC_COMMAND = 0,
11 | IPC_GET_WORKSPACES = 1,
12 | IPC_SUBSCRIBE = 2,
13 | IPC_GET_OUTPUTS = 3,
14 | IPC_GET_TREE = 4,
15 | IPC_GET_MARKS = 5,
16 | IPC_GET_BAR_CONFIG = 6,
17 | IPC_GET_VERSION = 7,
18 | IPC_GET_BINDING_MODES = 8,
19 | IPC_GET_CONFIG = 9,
20 | IPC_SEND_TICK = 10,
21 | IPC_SYNC = 11,
22 | IPC_GET_BINDING_STATE = 12,
23 |
24 | // sway-specific command types
25 | IPC_GET_INPUTS = 100,
26 | IPC_GET_SEATS = 101,
27 |
28 | // Events sent from sway to clients. Events have the highest bits set.
29 | IPC_EVENT_WORKSPACE = ((1<<31) | 0),
30 | IPC_EVENT_OUTPUT = ((1<<31) | 1),
31 | IPC_EVENT_MODE = ((1<<31) | 2),
32 | IPC_EVENT_WINDOW = ((1<<31) | 3),
33 | IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4),
34 | IPC_EVENT_BINDING = ((1<<31) | 5),
35 | IPC_EVENT_SHUTDOWN = ((1<<31) | 6),
36 | IPC_EVENT_TICK = ((1<<31) | 7),
37 |
38 | // sway-specific event types
39 | IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),
40 | IPC_EVENT_INPUT = ((1<<31) | 21),
41 | };
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/services/window_manager_service/sway/window_manager_service_sway.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "../window_manager_service.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _WMServiceSway;
10 | #define WM_SERVICE_SWAY_TYPE wm_service_sway_get_type()
11 | G_DECLARE_FINAL_TYPE(WMServiceSway, wm_service_sway, WM_SERVICE, SWAY, GObject);
12 |
13 | G_END_DECLS
14 |
15 | WindowManager *wm_service_sway_window_manager_init();
16 |
17 |
--------------------------------------------------------------------------------
/src/services/window_manager_service/window_manager_service.c:
--------------------------------------------------------------------------------
1 | #include "window_manager_service.h"
2 |
3 | #include "./sway/window_manager_service_sway.h"
4 |
5 | static WindowManager *global = NULL;
6 |
7 | char *WMWorkspaceEventStringTbl[WMWORKSPACE_EVENT_LEN] = {
8 | "CREATED", "DESTROYED", "FOCUSED", "MOVED", "RENAMED", "URGENT", "RELOAD",
9 | };
10 |
11 | // Initialize the window manager service
12 | int window_manager_service_init() {
13 | GSettings *settings =
14 | g_settings_new("org.ldelossa.way-shell.window-manager");
15 |
16 | char *backend = g_settings_get_string(settings, "backend");
17 |
18 | if (g_strcmp0(backend, "sway") == 0) {
19 | global = wm_service_sway_window_manager_init();
20 | } else {
21 | g_warning("Unknown backend: %s", backend);
22 | return -1;
23 | }
24 | return 0;
25 | }
26 |
27 | // Obtain the global window manager service, a call to
28 | // `window_manager_service_init` must be made before this.
29 | WindowManager *window_manager_service_get_global() { return global; }
30 |
--------------------------------------------------------------------------------
/src/switcher/switcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | // Helper macro to derefernce an embedded Switcher.
6 | #define SWITCHER(self) \
7 | self->switcher
8 |
9 | // Switcher abstracts the common widget components necessary to build a
10 | // on screen selector menu (think apps like rofi).
11 | //
12 | // The structure can be embedded into another struct or GOBject and the
13 | // init method can be called to initialize the component.
14 | //
15 | // Other methods then exist for more customization.
16 | // Because the struct is designed to be embedded, implementation of Switcher
17 | // widgets have access and control over all components.
18 | typedef struct _Switcher {
19 | // The main window that is created for the Switcher widget
20 | AdwWindow *win;
21 | // The main container for the Switcher widget.
22 | GtkBox *container;
23 | // Switcher widgets have their ListBox's scrolled after some defined max
24 | // size.
25 | GtkScrolledWindow *scrolled;
26 | // A list of contents within the switcher.
27 | GtkListBox *list;
28 | // The Search box which filters the items in list.
29 | GtkSearchEntry *search_entry;
30 | // A controller for keyboard shortcuts
31 | GtkEventController *key_controller;
32 | } Switcher;
33 |
34 | // Initialize a new Switcher widget.
35 | //
36 | // The has_list argument can be set to false to have a 'input only' Switcher that
37 | // can use its search box just to obtain user's input.
38 | void switcher_init(Switcher *self, gboolean has_list);
39 |
40 | // Returns the top choice in the Switcher's list.
41 | //
42 | // For example, calling this after the user has entered a search term will
43 | // return the closest matching item in the list.
44 | GtkListBoxRow *switcher_top_choice(Switcher *self);
45 | GtkListBoxRow *switcher_last_choice(Switcher *self);
46 |
--------------------------------------------------------------------------------
/src/workspace_switcher/workspace_switcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "workspace_switcher_workspace_widget.h"
6 |
7 | G_BEGIN_DECLS
8 |
9 | struct _WorkspaceSwitcher;
10 | #define WORKSPACE_SWITCHER_TYPE workspace_switcher_get_type()
11 | G_DECLARE_FINAL_TYPE(WorkspaceSwitcher, workspace_switcher, Workspace, Switcher,
12 | GObject);
13 |
14 | struct _WorkspaceModel;
15 | #define WORKSPACE_MODEL_TYPE workspace_model_get_type()
16 | G_DECLARE_FINAL_TYPE(WorkspaceModel, workspace_model, Workspace, Model,
17 | GObject);
18 |
19 | G_END_DECLS
20 |
21 | void workspace_switcher_activate(AdwApplication *app, gpointer user_data);
22 |
23 | WorkspaceSwitcher *workspace_switcher_get_global();
24 |
25 | void workspace_switcher_show(WorkspaceSwitcher *self);
26 |
27 | void workspace_switcher_hide(WorkspaceSwitcher *self);
28 |
29 | void workspace_switcher_toggle(WorkspaceSwitcher *self);
30 |
31 | void workspace_switcher_show_app_mode(WorkspaceSwitcher *self);
32 |
33 | void workspace_switcher_toggle_app_mode(WorkspaceSwitcher *self);
34 |
--------------------------------------------------------------------------------
/src/workspace_switcher/workspace_switcher_workspace_widget.c:
--------------------------------------------------------------------------------
1 | #include "./workspace_switcher_workspace_widget.h"
2 |
3 | #include
4 |
5 | enum signals { signals_n };
6 |
7 | typedef struct _WorkspaceSwitcherWorkspaceWidget {
8 | GObject parent_instance;
9 | GtkBox *container;
10 | GtkLabel *label;
11 | } WorkspaceSwitcherWorkspaceWidget;
12 | static guint workspace_switcher_workspace_widget_signals[signals_n] = {0};
13 | G_DEFINE_TYPE(WorkspaceSwitcherWorkspaceWidget,
14 | workspace_switcher_workspace_widget, G_TYPE_OBJECT);
15 |
16 | // stub out dispose, finalize, class_init and init methods.
17 | static void workspace_switcher_workspace_widget_dispose(GObject *object) {
18 | G_OBJECT_CLASS(workspace_switcher_workspace_widget_parent_class)
19 | ->dispose(object);
20 | }
21 |
22 | static void workspace_switcher_workspace_widget_finalize(GObject *object) {
23 | G_OBJECT_CLASS(workspace_switcher_workspace_widget_parent_class)
24 | ->finalize(object);
25 | }
26 |
27 | static void workspace_switcher_workspace_widget_class_init(
28 | WorkspaceSwitcherWorkspaceWidgetClass *class) {
29 | GObjectClass *object_class = G_OBJECT_CLASS(class);
30 | object_class->dispose = workspace_switcher_workspace_widget_dispose;
31 | object_class->finalize = workspace_switcher_workspace_widget_finalize;
32 | }
33 |
34 | static void workspace_switcher_workspace_widget_init_layout(
35 | WorkspaceSwitcherWorkspaceWidget *self) {
36 | self->container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
37 | gtk_widget_add_css_class(GTK_WIDGET(self->container), "switcher-entry");
38 |
39 | self->label = GTK_LABEL(gtk_label_new(""));
40 | gtk_box_append(self->container, GTK_WIDGET(self->label));
41 | }
42 |
43 | static void workspace_switcher_workspace_widget_init(
44 | WorkspaceSwitcherWorkspaceWidget *self) {
45 | workspace_switcher_workspace_widget_init_layout(self);
46 | }
47 |
48 | void workspace_switcher_workspace_widget_set_workspace_name(
49 | WorkspaceSwitcherWorkspaceWidget *self, const gchar *name) {
50 | gtk_label_set_text(self->label, name);
51 | }
52 |
53 | GtkWidget *workspace_switcher_workspace_widget_get_widget(
54 | WorkspaceSwitcherWorkspaceWidget *self) {
55 | return GTK_WIDGET(self->container);
56 | }
57 |
--------------------------------------------------------------------------------
/src/workspace_switcher/workspace_switcher_workspace_widget.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | struct _WorkspaceSwitcherWorkspaceWidget;
9 | #define WORKSPACE_SWITCHER_WORKSPACE_WIDGET_TYPE \
10 | workspace_switcher_workspace_widget_get_type()
11 | G_DECLARE_FINAL_TYPE(WorkspaceSwitcherWorkspaceWidget,
12 | workspace_switcher_workspace_widget, WorkspaceSwitcher,
13 | WorkspaceWidget, GObject);
14 |
15 | G_END_DECLS
16 |
17 | void workspace_switcher_workspace_widget_set_workspace_name(
18 | WorkspaceSwitcherWorkspaceWidget *self, const gchar *name);
19 |
20 | GtkWidget *workspace_switcher_workspace_widget_get_widget(
21 | WorkspaceSwitcherWorkspaceWidget *self);
22 |
--------------------------------------------------------------------------------
/way-sh/Makefile:
--------------------------------------------------------------------------------
1 | CC = gcc
2 | CFLAGS += -g3 -Wall
3 | SOURCES = $(shell find -type f -regex ".*\.c")
4 | OBJS = $(subst .c,.o,$(SOURCES))
5 | OBJS += ../lib/cmd_tree/cmd_tree.o
6 |
7 | way-sh: $(OBJS)
8 | $(CC) $(CFLAGS) $(LDFLAGS) -o way-sh $(OBJS)
9 |
10 | clean:
11 | rm -rf way-sh
12 | rm -rf $(OBJS)
13 |
--------------------------------------------------------------------------------
/way-sh/activities_cmd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "../lib/cmd_tree/include/cmd_tree.h"
8 | #include "../src/services/ipc_service/ipc_commands.h"
9 | #include "commands.h"
10 |
11 | static int activities_exec(void *ctx, uint8_t argc, char **argv) {
12 | printf(
13 | "Summary:\n"
14 | "\tManipulate the Activities widget.\n"
15 | "Commands:\n"
16 | "\tshow - show the Activities widget\n"
17 | "\thide - hide the Activities widget\n"
18 | "\ttoggle - toggle the Activities widget");
19 | return 0;
20 | };
21 |
22 | cmd_tree_node_t activities_root = {.name = "activities",
23 | .exec = activities_exec};
24 |
25 | static int activities_show_exec(void *ctx, uint8_t argc, char **argv) {
26 | int ret = 0;
27 | way_sh_ctx *way_ctx = ctx;
28 |
29 | IPCActivitiesShow msg = {.header.type = IPC_CMD_ACTIVITIES_SHOW};
30 |
31 | IPC_SEND_MSG(way_ctx, msg);
32 |
33 | if (ret == -1) {
34 | perror("[Error] Failed to send IPCActivitiesShow");
35 | return -1;
36 | }
37 |
38 | bool response = false;
39 | IPC_RECV_MSG(way_ctx, addr, &response);
40 |
41 | return response;
42 | };
43 |
44 | cmd_tree_node_t activities_show_cmd = {.name = "show",
45 | .exec = activities_show_exec};
46 |
47 | static int activities_hide_exec(void *ctx, uint8_t argc, char **argv) {
48 | int ret = 0;
49 | way_sh_ctx *way_ctx = ctx;
50 |
51 | IPCActivitiesHide msg = {.header.type = IPC_CMD_ACTIVITIES_HIDE};
52 |
53 | IPC_SEND_MSG(way_ctx, msg);
54 |
55 | if (ret == -1) {
56 | perror("[Error] Failed to send IPCActivitiesHide");
57 | return -1;
58 | }
59 |
60 | bool response = false;
61 | IPC_RECV_MSG(way_ctx, addr, &response);
62 |
63 | return response;
64 | };
65 |
66 | cmd_tree_node_t activities_hide_cmd = {.name = "hide",
67 | .exec = activities_hide_exec};
68 |
69 | static int activities_toggle_exec(void *ctx, uint8_t argc, char **argv) {
70 | int ret = 0;
71 | way_sh_ctx *way_ctx = ctx;
72 |
73 | IPCActivitiesToggle msg = {.header.type = IPC_CMD_ACTIVITIES_TOGGLE};
74 |
75 | IPC_SEND_MSG(way_ctx, msg);
76 |
77 | if (ret == -1) {
78 | perror("[Error] Failed to send IPCActivitiesToggle");
79 | return -1;
80 | }
81 |
82 | bool response = false;
83 | IPC_RECV_MSG(way_ctx, addr, &response);
84 |
85 | return response;
86 | };
87 |
88 | cmd_tree_node_t activities_toggle_cmd = {.name = "toggle",
89 | .exec = activities_toggle_exec};
90 |
91 | cmd_tree_node_t *activities_cmd() {
92 | cmd_tree_node_add_child(&activities_root, &activities_show_cmd);
93 | cmd_tree_node_add_child(&activities_root, &activities_hide_cmd);
94 | cmd_tree_node_add_child(&activities_root, &activities_toggle_cmd);
95 |
96 | return &activities_root;
97 | };
98 |
--------------------------------------------------------------------------------
/way-sh/app_switcher_cmd.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../lib/cmd_tree/include/cmd_tree.h"
9 | #include "../src/services/ipc_service/ipc_commands.h"
10 | #include "commands.h"
11 |
12 | static int app_switcher_exec(void *ctx, uint8_t argc, char **argv) {
13 | printf(
14 | "Summary:\n"
15 | "\tManipulate the AppSwitcher widget.\n"
16 | "Commands:\n"
17 | "\tshow - show the AppSwitcher widget\n"
18 | "\thide - hide the AppSwitcher widget\n"
19 | "\ttoggle - toggle the AppSwitcher widget");
20 | return 0;
21 | };
22 |
23 | cmd_tree_node_t app_switcher_root = {.name = "app-switcher",
24 | .exec = app_switcher_exec};
25 |
26 | static int app_switcher_show_exec(void *ctx, uint8_t argc, char **argv) {
27 | int ret = 0;
28 | way_sh_ctx *way_ctx = ctx;
29 |
30 | IPCAppSwitcherShow msg = {.header.type = IPC_CMD_APP_SWITCHER_SHOW};
31 |
32 | IPC_SEND_MSG(way_ctx, msg);
33 |
34 | if (ret == -1) {
35 | perror("[Error] Failed to send IPCAppSwitcherShow");
36 | return -1;
37 | }
38 |
39 | bool response = false;
40 | IPC_RECV_MSG(way_ctx, addr, &response);
41 |
42 | return response;
43 | };
44 |
45 | cmd_tree_node_t app_switcher_show_cmd = {.name = "show",
46 | .exec = app_switcher_show_exec};
47 |
48 | static int app_switcher_hide_exec(void *ctx, uint8_t argc, char **argv) {
49 | int ret = 0;
50 | way_sh_ctx *way_ctx = ctx;
51 |
52 | IPCAppSwitcherHide msg = {.header.type = IPC_CMD_APP_SWITCHER_HIDE};
53 |
54 | IPC_SEND_MSG(way_ctx, msg);
55 |
56 | if (ret == -1) {
57 | perror("[Error] Failed to send IPCAppSwitcherHide");
58 | return -1;
59 | }
60 |
61 | bool response = false;
62 | IPC_RECV_MSG(way_ctx, addr, &response);
63 |
64 | return response;
65 | };
66 |
67 | cmd_tree_node_t app_switcher_hide_cmd = {.name = "hide",
68 | .exec = app_switcher_hide_exec};
69 |
70 | static int app_switcher_toggle_exec(void *ctx, uint8_t argc, char **argv) {
71 | int ret = 0;
72 | way_sh_ctx *way_ctx = ctx;
73 |
74 | IPCAppSwitcherToggle msg = {.header.type = IPC_CMD_APP_SWITCHER_TOGGLE};
75 |
76 | IPC_SEND_MSG(way_ctx, msg);
77 |
78 | if (ret == -1) {
79 | perror("[Error] Failed to send IPCAppSwitcherToggle");
80 | return -1;
81 | }
82 |
83 | bool response = false;
84 | IPC_RECV_MSG(way_ctx, addr, &response);
85 |
86 | return response;
87 | };
88 |
89 | cmd_tree_node_t app_switcher_toggle_cmd = {.name = "toggle",
90 | .exec = app_switcher_toggle_exec};
91 |
92 | cmd_tree_node_t *app_switcher_cmd() {
93 | cmd_tree_node_add_child(&app_switcher_root, &app_switcher_show_cmd);
94 | cmd_tree_node_add_child(&app_switcher_root, &app_switcher_hide_cmd);
95 | cmd_tree_node_add_child(&app_switcher_root, &app_switcher_toggle_cmd);
96 |
97 | return &app_switcher_root;
98 | };
99 |
--------------------------------------------------------------------------------
/way-sh/bluelight_filter_cmd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "../lib/cmd_tree/include/cmd_tree.h"
8 | #include "../src/services/ipc_service/ipc_commands.h"
9 | #include "commands.h"
10 |
11 | static int bluelight_filter_exec(void *ctx, uint8_t argc, char **argv) {
12 | printf(
13 | "Summary:\n"
14 | "\tAdjust the bluelight (Night Light) filter.\n"
15 | "Commands:\n"
16 | "\tenable - turn on the bluelight filter\n"
17 | "\tdisable - turn off the bluelight filter");
18 | return 0;
19 | };
20 |
21 | // The root command for way-sh and is displayed when no other arguments are
22 | // provided to the CLI.
23 | //
24 | // A short help blurb is presented along with a list of all available root level
25 | // commands.
26 | cmd_tree_node_t bluelight_filter_root = {.name = "bluelight-filter",
27 | .exec = bluelight_filter_exec};
28 |
29 | static int bluelight_filter_enable_exec(void *ctx, uint8_t argc, char **argv) {
30 | int ret = 0;
31 | way_sh_ctx *way_ctx = ctx;
32 |
33 | IPCBlueLightFilterEnable msg = {.header.type =
34 | IPC_CMD_BLUELIGHT_FILTER_ENABLE};
35 |
36 | IPC_SEND_MSG(way_ctx, msg);
37 |
38 | if (ret == -1) {
39 | perror("[Error] Failed to send IPCBlueLightFilterEnable");
40 | return -1;
41 | }
42 |
43 | bool response = false;
44 | IPC_RECV_MSG(way_ctx, addr, &response);
45 |
46 | return response;
47 | };
48 |
49 | cmd_tree_node_t bluelight_filter_enable_cmd = {
50 | .name = "enable", .exec = bluelight_filter_enable_exec};
51 |
52 | static int bluelight_filter_disable_exec(void *ctx, uint8_t argc, char **argv) {
53 | int ret = 0;
54 | way_sh_ctx *way_ctx = ctx;
55 |
56 | IPCBlueLightFilterDisable msg = {.header.type =
57 | IPC_CMD_BLUELIGHT_FILTER_DISABLE};
58 |
59 | IPC_SEND_MSG(way_ctx, msg);
60 |
61 | if (ret == -1) {
62 | perror("[Error] Failed to send IPCBlueLightFilterDisable");
63 | return -1;
64 | }
65 |
66 | bool response = false;
67 | IPC_RECV_MSG(way_ctx, addr, &response);
68 |
69 | return response;
70 | };
71 |
72 | cmd_tree_node_t bluelight_filter_disable_cmd = {
73 | .name = "disable", .exec = bluelight_filter_disable_exec};
74 |
75 | cmd_tree_node_t *bluelight_filter_cmd() {
76 | cmd_tree_node_add_child(&bluelight_filter_root,
77 | &bluelight_filter_enable_cmd);
78 | cmd_tree_node_add_child(&bluelight_filter_root,
79 | &bluelight_filter_disable_cmd);
80 | return &bluelight_filter_root;
81 | };
82 |
--------------------------------------------------------------------------------
/way-sh/commands.h:
--------------------------------------------------------------------------------
1 | #include "../lib/cmd_tree/include/cmd_tree.h"
2 |
3 | #define IPC_SEND_MSG(way_ctx, msg) \
4 | struct sockaddr *addr = NULL; \
5 | struct sockaddr_un addr_un = { \
6 | .sun_family = AF_UNIX, \
7 | .sun_path = {0}, \
8 | }; \
9 | strcpy(&addr_un.sun_path[0], way_ctx->server_socket_path); \
10 | addr = (struct sockaddr *)&addr_un; \
11 | ret = sendto(way_ctx->client_sock, &msg, sizeof(msg), 0, addr, \
12 | sizeof(addr_un))
13 |
14 | #define IPC_RECV_MSG(way_ctx, addr, bool) \
15 | recvfrom(way_ctx->client_sock, bool, sizeof(bool), 0, addr, 0)
16 |
17 | typedef struct _ctx {
18 | char *server_socket_path;
19 | int client_sock;
20 | } way_sh_ctx;
21 |
22 | // The root command node.
23 | //
24 | // It is exec'd when no command is provided to way-sh and provides a short
25 | // description of way-sh's usage.
26 | //
27 | // Defined in ./root.c
28 | extern cmd_tree_node_t root_cmd;
29 |
30 | // The message_tray comand root.
31 | //
32 | // Subcommands off this node deal with showing or manipulating the Message Tray
33 | // UI component.
34 | cmd_tree_node_t *message_tray_cmd();
35 |
36 | // The volume command root.
37 | //
38 | // Subcommands off this node deal with adjusting the default audio sink's
39 | // volume.
40 | cmd_tree_node_t *volume_cmd();
41 |
42 | // The Brightness command
43 | //
44 | // Subcommands off this node deal with adjusting the default display's
45 | // brightness.
46 | cmd_tree_node_t *brightness_cmd();
47 |
48 | // The Theme command
49 | //
50 | // Subcommands off this node deal with adjusting Way-Shell' theme.
51 | cmd_tree_node_t *theme_cmd();
52 |
53 | // The Activities command
54 | //
55 | // Subcommands off this node deal with showing and hiding the Activities widget.
56 | cmd_tree_node_t *activities_cmd();
57 |
58 | // The App Switcher command
59 | //
60 | // Subcommands off this node deal with showing and hiding the App Switcher
61 | // widget.
62 | cmd_tree_node_t *app_switcher_cmd();
63 |
64 | // The Workspace Switcher command
65 | //
66 | // Subcommands off this node deal with showing and hiding the Workspace Switcher
67 | // widget.
68 | cmd_tree_node_t *workspace_switcher_cmd();
69 |
70 | // The Output Switcher command
71 | //
72 | // Subcommands off this node deal with showing and hiding the Output Switcher
73 | // widget.
74 | cmd_tree_node_t *output_switcher_cmd();
75 |
76 | // The Workspace App Switcher command
77 | //
78 | // Subcommands off this node deal with showing and hiding the Workspace App
79 | // Switcher widget.
80 | cmd_tree_node_t *workspace_app_switcher_cmd();
81 |
82 | // The Night Light command
83 | //
84 | // Subcommands off this node deal with enabling and disabling the Night Light
85 | cmd_tree_node_t *bluelight_filter_cmd();
86 |
87 | // The Rename Switcher command
88 | //
89 | // Subcommands off this node deal with showing and hiding the Rename Switcher
90 | cmd_tree_node_t *rename_switcher_cmd();
91 |
--------------------------------------------------------------------------------
/way-sh/message_tray_cmd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "../lib/cmd_tree/include/cmd_tree.h"
8 | #include "../src/services/ipc_service/ipc_commands.h"
9 | #include "commands.h"
10 |
11 | static int message_tray_exec(void *ctx, uint8_t argc, char **argv) {
12 | printf(
13 | "Summary:\n"
14 | "\tManipulate the Message Tray component.\n"
15 | "Commands:\n"
16 | "\topen - open the message tray component on the primary monitor");
17 | return 0;
18 | };
19 |
20 | // The root command for way-sh and is displayed when no other arguments are
21 | // provided to the CLI.
22 | //
23 | // A short help blurb is presented along with a list of all available root level
24 | // commands.
25 | cmd_tree_node_t message_tray_root = {.name = "message-tray",
26 | .exec = message_tray_exec};
27 |
28 | static int message_tray_open_exec(void *ctx, uint8_t argc, char **argv) {
29 | int ret = 0;
30 | way_sh_ctx *way_ctx = ctx;
31 |
32 | IPCMessageTrayOpen msg = {.header.type = IPC_CMD_MESSAGE_TRAY_OPEN};
33 |
34 | IPC_SEND_MSG(way_ctx, msg);
35 |
36 | if (ret == -1) {
37 | perror("[Error] Failed to send IPCMessageTrayOpen");
38 | return -1;
39 | }
40 |
41 | bool response = false;
42 | IPC_RECV_MSG(way_ctx, addr, &response);
43 |
44 | return response;
45 | };
46 |
47 | cmd_tree_node_t message_tray_open_cmd = {.name = "open",
48 | .exec = message_tray_open_exec};
49 |
50 | cmd_tree_node_t *message_tray_cmd() {
51 | cmd_tree_node_add_child(&message_tray_root, &message_tray_open_cmd);
52 | return &message_tray_root;
53 | };
54 |
--------------------------------------------------------------------------------
/way-sh/output_switcher_cmd.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../lib/cmd_tree/include/cmd_tree.h"
9 | #include "../src/services/ipc_service/ipc_commands.h"
10 | #include "commands.h"
11 |
12 | static int output_switcher_exec(void *ctx, uint8_t argc, char **argv) {
13 | printf(
14 | "Summary:\n"
15 | "\tManipulate the OutputSwitcher widget.\n"
16 | "Commands:\n"
17 | "\tshow - show the OutputSwitcher widget\n"
18 | "\thide - hide the OutputSwitcher widget\n"
19 | "\ttoggle - toggle the OutputSwitcher widget");
20 | return 0;
21 | };
22 |
23 | cmd_tree_node_t output_switcher_root = {.name = "output-switcher",
24 | .exec = output_switcher_exec};
25 |
26 | static int output_switcher_show_exec(void *ctx, uint8_t argc, char **argv) {
27 | int ret = 0;
28 | way_sh_ctx *way_ctx = ctx;
29 |
30 | IPCOutputSwitcherShow msg = {.header.type = IPC_CMD_OUTPUT_SWITCHER_SHOW};
31 |
32 | IPC_SEND_MSG(way_ctx, msg);
33 |
34 | if (ret == -1) {
35 | perror("[Error] Failed to send IPCOutputSwitcherShow");
36 | return -1;
37 | }
38 |
39 | bool response = false;
40 | IPC_RECV_MSG(way_ctx, addr, &response);
41 |
42 | return response;
43 | };
44 |
45 | cmd_tree_node_t output_switcher_show_cmd = {.name = "show",
46 | .exec = output_switcher_show_exec};
47 |
48 | static int output_switcher_hide_exec(void *ctx, uint8_t argc, char **argv) {
49 | int ret = 0;
50 | way_sh_ctx *way_ctx = ctx;
51 |
52 | IPCOutputSwitcherHide msg = {.header.type = IPC_CMD_OUTPUT_SWITCHER_HIDE};
53 |
54 | IPC_SEND_MSG(way_ctx, msg);
55 |
56 | if (ret == -1) {
57 | perror("[Error] Failed to send IPCOutputSwitcherHide");
58 | return -1;
59 | }
60 |
61 | bool response = false;
62 | IPC_RECV_MSG(way_ctx, addr, &response);
63 |
64 | return response;
65 | };
66 |
67 | cmd_tree_node_t output_switcher_hide_cmd = {.name = "hide",
68 | .exec = output_switcher_hide_exec};
69 |
70 | static int output_switcher_toggle_exec(void *ctx, uint8_t argc, char **argv) {
71 | int ret = 0;
72 | way_sh_ctx *way_ctx = ctx;
73 |
74 | IPCOutputSwitcherToggle msg = {.header.type = IPC_CMD_OUTPUT_SWITCHER_TOGGLE};
75 |
76 | IPC_SEND_MSG(way_ctx, msg);
77 |
78 | if (ret == -1) {
79 | perror("[Error] Failed to send IPCOutputSwitcherToggle");
80 | return -1;
81 | }
82 |
83 | bool response = false;
84 | IPC_RECV_MSG(way_ctx, addr, &response);
85 |
86 | return response;
87 | };
88 |
89 | cmd_tree_node_t output_switcher_toggle_cmd = {.name = "toggle",
90 | .exec = output_switcher_toggle_exec};
91 |
92 | cmd_tree_node_t *output_switcher_cmd() {
93 | cmd_tree_node_add_child(&output_switcher_root, &output_switcher_show_cmd);
94 | cmd_tree_node_add_child(&output_switcher_root, &output_switcher_hide_cmd);
95 | cmd_tree_node_add_child(&output_switcher_root, &output_switcher_toggle_cmd);
96 |
97 | return &output_switcher_root;
98 | };
99 |
--------------------------------------------------------------------------------
/way-sh/rename_switcher_cmd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "../lib/cmd_tree/include/cmd_tree.h"
8 | #include "../src/services/ipc_service/ipc_commands.h"
9 | #include "commands.h"
10 |
11 | static int rename_switcher_exec(void *ctx, uint8_t argc, char **argv) {
12 | printf(
13 | "Summary:\n"
14 | "\tManipulate the RenameSwitcher widget.\n"
15 | "Commands:\n"
16 | "\tshow - show the RenameSwitcher widget\n"
17 | "\thide - hide the RenameSwitcher widget\n"
18 | "\ttoggle - toggle the RenameSwitcher widget");
19 | return 0;
20 | };
21 |
22 | cmd_tree_node_t rename_switcher_root = {.name = "rename-switcher",
23 | .exec = rename_switcher_exec};
24 |
25 | static int rename_switcher_show_exec(void *ctx, uint8_t argc, char **argv) {
26 | int ret = 0;
27 | way_sh_ctx *way_ctx = ctx;
28 |
29 | IPCRenameSwitcherShow msg = {.header.type = IPC_CMD_RENAME_SWITCHER_SHOW};
30 |
31 | IPC_SEND_MSG(way_ctx, msg);
32 |
33 | if (ret == -1) {
34 | perror("[Error] Failed to send IPCRenameSwitcherShow");
35 | return -1;
36 | }
37 |
38 | bool response = false;
39 | IPC_RECV_MSG(way_ctx, addr, &response);
40 |
41 | return response;
42 | };
43 |
44 | cmd_tree_node_t rename_switcher_show_cmd = {.name = "show",
45 | .exec = rename_switcher_show_exec};
46 |
47 | static int rename_switcher_hide_exec(void *ctx, uint8_t argc, char **argv) {
48 | int ret = 0;
49 | way_sh_ctx *way_ctx = ctx;
50 |
51 | IPCRenameSwitcherHide msg = {.header.type = IPC_CMD_RENAME_SWITCHER_HIDE};
52 |
53 | IPC_SEND_MSG(way_ctx, msg);
54 |
55 | if (ret == -1) {
56 | perror("[Error] Failed to send IPCRenameSwitcherHide");
57 | return -1;
58 | }
59 |
60 | bool response = false;
61 | IPC_RECV_MSG(way_ctx, addr, &response);
62 |
63 | return response;
64 | };
65 |
66 | cmd_tree_node_t rename_switcher_hide_cmd = {.name = "hide",
67 | .exec = rename_switcher_hide_exec};
68 |
69 | static int rename_switcher_toggle_exec(void *ctx, uint8_t argc, char **argv) {
70 | int ret = 0;
71 | way_sh_ctx *way_ctx = ctx;
72 |
73 | IPCRenameSwitcherToggle msg = {.header.type = IPC_CMD_RENAME_SWITCHER_TOGGLE};
74 |
75 | IPC_SEND_MSG(way_ctx, msg);
76 |
77 | if (ret == -1) {
78 | perror("[Error] Failed to send IPCRenameSwitcherToggle");
79 | return -1;
80 | }
81 |
82 | bool response = false;
83 | IPC_RECV_MSG(way_ctx, addr, &response);
84 |
85 | return response;
86 | };
87 |
88 | cmd_tree_node_t rename_switcher_toggle_cmd = {.name = "toggle",
89 | .exec = rename_switcher_toggle_exec};
90 |
91 | cmd_tree_node_t *rename_switcher_cmd() {
92 | cmd_tree_node_add_child(&rename_switcher_root, &rename_switcher_show_cmd);
93 | cmd_tree_node_add_child(&rename_switcher_root, &rename_switcher_hide_cmd);
94 | cmd_tree_node_add_child(&rename_switcher_root, &rename_switcher_toggle_cmd);
95 |
96 | return &rename_switcher_root;
97 | };
98 |
--------------------------------------------------------------------------------
/way-sh/root.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "../lib/cmd_tree/include/cmd_tree.h"
4 |
5 | static int root_exec(void *ctx, uint8_t argc, char **argv) {
6 | printf(
7 | "Usage: \n"
8 | "\tway-sh COMMAND [SUBCOMMAND...] [ARGUMENTS]\n"
9 | "Commands: \n"
10 | "\tmessage-tray\n"
11 | "\tvolume\n"
12 | "\tbrightness\n"
13 | "\ttheme\n"
14 | "\tactivities\n"
15 | "\tapp-switcher\n"
16 | "\tworkspace-switcher\n"
17 | "\tworkspace-app-switcher\n"
18 | "\toutput-switcher\n"
19 | "\tbluelight-filter\n"
20 | "\trename-switcher\n"
21 | );
22 | return 0;
23 | };
24 |
25 | // The root command for way-sh and is displayed when no other arguments are
26 | // provided to the CLI.
27 | //
28 | // A short help blurb is presented along with a list of all available root level
29 | // commands.
30 | cmd_tree_node_t root_cmd = {.exec = root_exec};
31 |
--------------------------------------------------------------------------------
/way-sh/theme_cmd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "../lib/cmd_tree/include/cmd_tree.h"
8 | #include "../src/services/ipc_service/ipc_commands.h"
9 | #include "commands.h"
10 |
11 | static int theme_exec(void *ctx, uint8_t argc, char **argv) {
12 | printf(
13 | "Summary:\n"
14 | "\tAdjust aspects of Way-Shell's theme.\n"
15 | "\n"
16 | "\tThe dump commands will write the respective theme to\n"
17 | "\t$HOME/.config/way-shell/way-shell-{light|dark}.css for editing.\n"
18 | "\n"
19 | "\tToggling the theme (light-to-dark or vice versa) will show the \n"
20 | "\tresults of any edits.\n"
21 | "Commands:\n"
22 | "\tdark - set dark theme\n"
23 | "\tlight - set light theme\n"
24 | "\tdump-dark - dump dark theme\n"
25 | "\tdump-light - dump light theme\n");
26 | return 0;
27 | };
28 |
29 | cmd_tree_node_t theme_root = {.name = "theme", .exec = theme_exec};
30 |
31 | static int theme_dark_exec(void *ctx, uint8_t argc, char **argv) {
32 | int ret = 0;
33 | way_sh_ctx *way_ctx = ctx;
34 |
35 | IPCThemeDark msg = {.header.type = IPC_CMD_THEME_DARK};
36 |
37 | IPC_SEND_MSG(way_ctx, msg);
38 |
39 | if (ret == -1) {
40 | perror("[Error] Failed to send IPCThemeDark");
41 | return -1;
42 | }
43 |
44 | bool response = false;
45 | IPC_RECV_MSG(way_ctx, addr, &response);
46 |
47 | return response;
48 | };
49 |
50 | cmd_tree_node_t theme_dark_cmd = {.name = "dark", .exec = theme_dark_exec};
51 |
52 | static int theme_light_exec(void *ctx, uint8_t argc, char **argv) {
53 | int ret = 0;
54 | way_sh_ctx *way_ctx = ctx;
55 |
56 | IPCThemeLight msg = {.header.type = IPC_CMD_THEME_LIGHT};
57 |
58 | IPC_SEND_MSG(way_ctx, msg);
59 |
60 | if (ret == -1) {
61 | perror("[Error] Failed to send IPCThemeLight");
62 | return -1;
63 | }
64 |
65 | bool response = false;
66 | IPC_RECV_MSG(way_ctx, addr, &response);
67 |
68 | return response;
69 | };
70 |
71 | cmd_tree_node_t theme_light_cmd = {.name = "light", .exec = theme_light_exec};
72 |
73 | static int theme_dump_light_exec(void *ctx, uint8_t argc, char **argv) {
74 | int ret = 0;
75 | way_sh_ctx *way_ctx = ctx;
76 |
77 | IPCDumpLightTheme msg = {.header.type = IPC_CMD_DUMP_LIGHT_THEME};
78 |
79 | IPC_SEND_MSG(way_ctx, msg);
80 |
81 | if (ret == -1) {
82 | perror("[Error] Failed to send IPCDumpLightTheme");
83 | return -1;
84 | }
85 |
86 | bool response = false;
87 | IPC_RECV_MSG(way_ctx, addr, &response);
88 |
89 | return response;
90 | };
91 |
92 | cmd_tree_node_t theme_dump_light_cmd = {.name = "dump-light",
93 | .exec = theme_dump_light_exec};
94 |
95 | static int theme_dump_dark_exec(void *ctx, uint8_t argc, char **argv) {
96 | int ret = 0;
97 | way_sh_ctx *way_ctx = ctx;
98 |
99 | IPCDumpDarkTheme msg = {.header.type = IPC_CMD_DUMP_DARK_THEME};
100 |
101 | IPC_SEND_MSG(way_ctx, msg);
102 |
103 | if (ret == -1) {
104 | perror("[Error] Failed to send IPCDumpDarkTheme");
105 | return -1;
106 | }
107 |
108 | bool response = false;
109 | IPC_RECV_MSG(way_ctx, addr, &response);
110 |
111 | return response;
112 | };
113 |
114 | cmd_tree_node_t theme_dump_dark_cmd = {.name = "dump-dark",
115 | .exec = theme_dump_dark_exec};
116 |
117 | cmd_tree_node_t *theme_cmd() {
118 | cmd_tree_node_add_child(&theme_root, &theme_dark_cmd);
119 | cmd_tree_node_add_child(&theme_root, &theme_light_cmd);
120 | cmd_tree_node_add_child(&theme_root, &theme_dump_light_cmd);
121 | cmd_tree_node_add_child(&theme_root, &theme_dump_dark_cmd);
122 |
123 | return &theme_root;
124 | }
125 |
--------------------------------------------------------------------------------
/way-sh/workspace_app_switcher_cmd.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../lib/cmd_tree/include/cmd_tree.h"
9 | #include "../src/services/ipc_service/ipc_commands.h"
10 | #include "commands.h"
11 |
12 | static int workspace_app_switcher_exec(void *ctx, uint8_t argc, char **argv) {
13 | printf(
14 | "Summary:\n"
15 | "\tManipulate the WorkspaceAppSwitcher widget.\n"
16 | "Commands:\n"
17 | "\tshow - show the WorkspaceAppSwitcher widget\n"
18 | "\thide - hide the WorkspaceAppSwitcher widget\n"
19 | "\ttoggle - toggle the WorkspaceAppSwitcher widget");
20 | return 0;
21 | };
22 |
23 | cmd_tree_node_t workspace_app_switcher_root = {.name = "workspace-app-switcher",
24 | .exec = workspace_app_switcher_exec};
25 |
26 | static int workspace_app_switcher_show_exec(void *ctx, uint8_t argc, char **argv) {
27 | int ret = 0;
28 | way_sh_ctx *way_ctx = ctx;
29 |
30 | IPCWorkspaceAppSwitcherShow msg = {.header.type = IPC_CMD_WORKSPACE_APP_SWITCHER_SHOW};
31 |
32 | IPC_SEND_MSG(way_ctx, msg);
33 |
34 | if (ret == -1) {
35 | perror("[Error] Failed to send IPCWorkspaceAppSwitcherShow");
36 | return -1;
37 | }
38 |
39 | bool response = false;
40 | IPC_RECV_MSG(way_ctx, addr, &response);
41 |
42 | return response;
43 | };
44 |
45 | cmd_tree_node_t workspace_app_switcher_show_cmd = {.name = "show",
46 | .exec = workspace_app_switcher_show_exec};
47 |
48 | static int workspace_app_switcher_hide_exec(void *ctx, uint8_t argc, char **argv) {
49 | int ret = 0;
50 | way_sh_ctx *way_ctx = ctx;
51 |
52 | IPCWorkspaceAppSwitcherHide msg = {.header.type = IPC_CMD_WORKSPACE_APP_SWITCHER_HIDE};
53 |
54 | IPC_SEND_MSG(way_ctx, msg);
55 |
56 | if (ret == -1) {
57 | perror("[Error] Failed to send IPCWorkspaceAppSwitcherHide");
58 | return -1;
59 | }
60 |
61 | bool response = false;
62 | IPC_RECV_MSG(way_ctx, addr, &response);
63 |
64 | return response;
65 | };
66 |
67 | cmd_tree_node_t workspace_app_switcher_hide_cmd = {.name = "hide",
68 | .exec = workspace_app_switcher_hide_exec};
69 |
70 | static int workspace_app_switcher_toggle_exec(void *ctx, uint8_t argc, char **argv) {
71 | int ret = 0;
72 | way_sh_ctx *way_ctx = ctx;
73 |
74 | IPCWorkspaceAppSwitcherToggle msg = {.header.type = IPC_CMD_WORKSPACE_APP_SWITCHER_TOGGLE};
75 |
76 | IPC_SEND_MSG(way_ctx, msg);
77 |
78 | if (ret == -1) {
79 | perror("[Error] Failed to send IPCWorkspaceAppSwitcherToggle");
80 | return -1;
81 | }
82 |
83 | bool response = false;
84 | IPC_RECV_MSG(way_ctx, addr, &response);
85 |
86 | return response;
87 | };
88 |
89 | cmd_tree_node_t workspace_app_switcher_toggle_cmd = {.name = "toggle",
90 | .exec = workspace_app_switcher_toggle_exec};
91 |
92 | cmd_tree_node_t *workspace_app_switcher_cmd() {
93 | cmd_tree_node_add_child(&workspace_app_switcher_root, &workspace_app_switcher_show_cmd);
94 | cmd_tree_node_add_child(&workspace_app_switcher_root, &workspace_app_switcher_hide_cmd);
95 | cmd_tree_node_add_child(&workspace_app_switcher_root, &workspace_app_switcher_toggle_cmd);
96 |
97 | return &workspace_app_switcher_root;
98 | };
99 |
--------------------------------------------------------------------------------
/way-sh/workspace_switcher_cmd.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../lib/cmd_tree/include/cmd_tree.h"
9 | #include "../src/services/ipc_service/ipc_commands.h"
10 | #include "commands.h"
11 |
12 | static int workspace_switcher_exec(void *ctx, uint8_t argc, char **argv) {
13 | printf(
14 | "Summary:\n"
15 | "\tManipulate the WorkspaceSwitcher widget.\n"
16 | "Commands:\n"
17 | "\tshow - show the WorkspaceSwitcher widget\n"
18 | "\thide - hide the WorkspaceSwitcher widget\n"
19 | "\ttoggle - toggle the WorkspaceSwitcher widget");
20 | return 0;
21 | };
22 |
23 | cmd_tree_node_t workspace_switcher_root = {.name = "workspace-switcher",
24 | .exec = workspace_switcher_exec};
25 |
26 | static int workspace_switcher_show_exec(void *ctx, uint8_t argc, char **argv) {
27 | int ret = 0;
28 | way_sh_ctx *way_ctx = ctx;
29 |
30 | IPCWorkspaceSwitcherShow msg = {.header.type = IPC_CMD_WORKSPACE_SWITCHER_SHOW};
31 |
32 | IPC_SEND_MSG(way_ctx, msg);
33 |
34 | if (ret == -1) {
35 | perror("[Error] Failed to send IPCWorkspaceSwitcherShow");
36 | return -1;
37 | }
38 |
39 | bool response = false;
40 | IPC_RECV_MSG(way_ctx, addr, &response);
41 |
42 | return response;
43 | };
44 |
45 | cmd_tree_node_t workspace_switcher_show_cmd = {.name = "show",
46 | .exec = workspace_switcher_show_exec};
47 |
48 | static int workspace_switcher_hide_exec(void *ctx, uint8_t argc, char **argv) {
49 | int ret = 0;
50 | way_sh_ctx *way_ctx = ctx;
51 |
52 | IPCWorkspaceSwitcherHide msg = {.header.type = IPC_CMD_WORKSPACE_SWITCHER_HIDE};
53 |
54 | IPC_SEND_MSG(way_ctx, msg);
55 |
56 | if (ret == -1) {
57 | perror("[Error] Failed to send IPCWorkspaceSwitcherHide");
58 | return -1;
59 | }
60 |
61 | bool response = false;
62 | IPC_RECV_MSG(way_ctx, addr, &response);
63 |
64 | return response;
65 | };
66 |
67 | cmd_tree_node_t workspace_switcher_hide_cmd = {.name = "hide",
68 | .exec = workspace_switcher_hide_exec};
69 |
70 | static int workspace_switcher_toggle_exec(void *ctx, uint8_t argc, char **argv) {
71 | int ret = 0;
72 | way_sh_ctx *way_ctx = ctx;
73 |
74 | IPCWorkspaceSwitcherToggle msg = {.header.type = IPC_CMD_WORKSPACE_SWITCHER_TOGGLE};
75 |
76 | IPC_SEND_MSG(way_ctx, msg);
77 |
78 | if (ret == -1) {
79 | perror("[Error] Failed to send IPCWorkspaceSwitcherToggle");
80 | return -1;
81 | }
82 |
83 | bool response = false;
84 | IPC_RECV_MSG(way_ctx, addr, &response);
85 |
86 | return response;
87 | };
88 |
89 | cmd_tree_node_t workspace_switcher_toggle_cmd = {.name = "toggle",
90 | .exec = workspace_switcher_toggle_exec};
91 |
92 | cmd_tree_node_t *workspace_switcher_cmd() {
93 | cmd_tree_node_add_child(&workspace_switcher_root, &workspace_switcher_show_cmd);
94 | cmd_tree_node_add_child(&workspace_switcher_root, &workspace_switcher_hide_cmd);
95 | cmd_tree_node_add_child(&workspace_switcher_root, &workspace_switcher_toggle_cmd);
96 |
97 | return &workspace_switcher_root;
98 | };
99 |
--------------------------------------------------------------------------------
/way-shell.spec:
--------------------------------------------------------------------------------
1 | %define _userunitdir /usr/lib/systemd/user
2 |
3 | Name: way-shell
4 | Version: 0.0.10
5 | Release: 1%{?dist}
6 | Summary: A Gnome-like desktop shell for Wayland compositors.
7 | License: MIT
8 |
9 | URL: https://github.com/ldelossa/way-shell
10 | Source0: https://github.com/ldelossa/way-shell/archive/refs/tags/v0.0.10.tar.gz
11 |
12 | BuildRequires: gcc
13 | BuildRequires: make
14 | BuildRequires: pkgconfig
15 | BuildRequires: meson
16 | BuildRequires: cmake
17 | BuildRequires: gtk-doc
18 | BuildRequires: wayland-devel
19 | BuildRequires: glib2-devel
20 |
21 | BuildRequires: pkgconfig(libadwaita-1)
22 | BuildRequires: pkgconfig(upower-glib)
23 | BuildRequires: pkgconfig(wireplumber-0.5)
24 | BuildRequires: pkgconfig(json-glib-1.0)
25 | BuildRequires: pkgconfig(libnm)
26 | BuildRequires: pkgconfig(libpulse)
27 | BuildRequires: pkgconfig(libpulse-simple)
28 | BuildRequires: pkgconfig(libpulse-mainloop-glib)
29 | BuildRequires: pkgconfig(wayland-client)
30 | BuildRequires: pkgconfig(wayland-protocols)
31 | BuildRequires: pkgconfig(gio-unix-2.0)
32 | BuildRequires: pkgconfig(gtk4-layer-shell-0)
33 |
34 | Requires: NetworkManager
35 | Requires: wireplumber
36 | Requires: upower
37 | Requires: power-profiles-daemon
38 | Requires: systemd
39 | Requires: wayland-devel
40 |
41 | %description
42 | A Gnome inspired desktop shell for Wayland compositors/window managers written
43 | in C and Gtk4.
44 |
45 | Way-Shell expects a Gnome-like environment to be available.
46 | This means DBus must be running and the following services must be available:
47 |
48 | - Logind
49 | - NetworkManager
50 | - WirePlumber/Pipewire
51 | - PowerProfiles Daemon
52 | - UPower
53 |
54 | If you're using Fedora these services should be available by default.
55 |
56 | Currently Way-Shell only supports Sway but this will change as the project
57 | matures.
58 |
59 | %prep
60 | %setup -n way-shell-0.0.10
61 |
62 | %build
63 | make %{?_smp_mflags}
64 |
65 | %install
66 | make install DESTDIR=%{buildroot}
67 |
68 | %post
69 | glib-compile-schemas %{_datadir}/glib-2.0/schemas
70 |
71 | %postun
72 | glib-compile-schemas %{_datadir}/glib-2.0/schemas
73 |
74 | %files
75 | %{_bindir}/way-shell
76 | %{_bindir}/way-sh
77 | %{_datadir}/glib-2.0/schemas/org.ldelossa.way-shell.gschema.xml
78 | %{_userunitdir}/way-shell.service
79 |
80 | %changelog
81 | * Mon May 27 2024 Louis DeLosSantos
82 | - Initial packaging
83 |
--------------------------------------------------------------------------------