1+ import type { Program } from "../types" ;
2+
3+ export default {
4+ name : "taskbar_test" ,
5+ description : "" ,
6+ usage_suffix : "" ,
7+ arg_descriptions : { } ,
8+ compat : "2.0.0" ,
9+ hide_from_help : true ,
10+ completion : async ( ) => [ ] ,
11+ main : async ( data ) => {
12+ // extract from data to make code less verbose
13+ const { kernel, term, process, shell } = data ;
14+
15+ if ( ! kernel . has_window_manager ( ) ) {
16+ term . writeln ( "This program requires a window manager." ) ;
17+ return 1 ;
18+ }
19+
20+ const wind = process . create_window ( ) ;
21+
22+ wind . title = "Taskbar" ;
23+
24+ wind . set_custom_flag ( "no-top-bar" , true ) ;
25+
26+ wind . x = "0vw" ;
27+ wind . y = "92.5vh" ;
28+
29+ wind . height = "7.5vh" ;
30+ wind . width = "100vw" ;
31+
32+ const buttons = document . createElement ( "div" ) ;
33+ buttons . style . display = "flex" ;
34+ buttons . style . height = "100%" ;
35+ buttons . style . alignItems = "center" ;
36+ buttons . style . gap = "1vh" ;
37+ buttons . style . padding = "0 1vh" ;
38+
39+ wind . dom . appendChild ( buttons ) ;
40+
41+ const fsedit_button = document . createElement ( "button" ) ;
42+ fsedit_button . innerText = "FSEdit" ;
43+ fsedit_button . style . height = "100%" ;
44+ fsedit_button . style . fontSize = "2vh" ;
45+ fsedit_button . onclick = ( ) => {
46+ kernel . spawn ( "fsedit" , [ ] , shell ) ;
47+ } ;
48+
49+ buttons . appendChild ( fsedit_button ) ;
50+
51+ // if minecraft is installed, add a button for it
52+ const fs = kernel . get_fs ( ) ;
53+ if ( await fs . exists ( "/usr/bin/minecraft" ) ) {
54+ const mc_button = document . createElement ( "button" ) ;
55+ mc_button . style . height = "100%" ;
56+ mc_button . style . fontSize = "2vh" ;
57+ mc_button . onclick = ( ) => {
58+ kernel . spawn ( "minecraft" , [ ] , shell ) ;
59+ } ;
60+
61+ const mc_image = document . createElement ( "img" ) ;
62+ mc_image . src = "https://brandlogos.net/wp-content/uploads/2022/07/minecraft-logo_brandlogos.net_faqdi-512x560.png" ;
63+ mc_image . style . height = "100%" ;
64+ mc_image . style . objectFit = "contain" ;
65+ mc_image . alt = "Minecraft" ;
66+ mc_image . draggable = false ;
67+ mc_button . appendChild ( mc_image ) ;
68+
69+ buttons . appendChild ( mc_button ) ;
70+ }
71+
72+ wind . show ( ) ;
73+
74+ process . detach ( ) ;
75+ return 0 ;
76+ }
77+ } as Program ;
0 commit comments